\ManaPHP\Data\DbQuery

Summary

Methods
Properties
Constants
getIterator()
jsonSerialize()
setModel()
getModel()
shard()
getShards()
getUniqueShard()
from()
distinct()
search()
where()
whereDateBetween()
groupBy()
orderBy()
indexBy()
limit()
with()
page()
setFetchType()
fetch()
paginate()
forceUseMaster()
first()
get()
all()
value()
sum()
max()
min()
avg()
options()
when()
whereDate()
whereMonth()
whereYear()
innerJoin()
leftJoin()
rightJoin()
getInstance()
getShared()
inject()
__get()
__set()
__isset()
attachEvent()
detachEvent()
peekEvent()
fireEvent()
on()
off()
emit()
__debugInfo()
dump()
toArray()
__construct()
setDb()
select()
join()
whereEq()
whereCmp()
whereMod()
whereExpr()
whereBetween()
whereNotBetween()
whereIn()
whereRaw()
whereNotIn()
whereInset()
whereNotInset()
whereLike()
whereNotLike()
whereContains()
whereNotContains()
whereStartsWith()
whereNotStartsWith()
whereEndsWith()
whereNotEndsWith()
whereRegex()
whereNotRegex()
whereNull()
whereNotNull()
where1v1()
having()
forUpdate()
getSql()
getBind()
setBind()
execute()
aggregate()
count()
exists()
__toString()
values()
update()
delete()
$request
$relationsManager
$alias
$eventsManager
$logger
$configure
$settings
$crypt
$identity
$cache
$httpClient
$restClient
$db
$redisCache
$redisDb
$redisBroker
$mongodb
$rabbitmq
$elasticsearch
$mailer
$bosClient
$wspClient
$coroutineManager
$wsClient
$pubSub
$_context
$_di
No constants found
_createContext()
_getDb()
_buildGroup()
_buildOrder()
_buildSql()
_query()
_buildAggregate()
$_db
$_table
$_alias
$_fields
$_limit
$_offset
$_distinct
$_model
$_multiple
$_with
$_order
$_group
$_index
$_aggregate
$_force_master
$_shard_context
$_shard_strategy
$_object_id
$_on
$_injections
$_joins
$_conditions
$_having
$_for_update
$_bind
$_sql
N/A
No private methods found
No private properties found
N/A

Properties

$request

$request : \ManaPHP\Http\RequestInterface

Type

\ManaPHP\Http\RequestInterface

$relationsManager

$relationsManager : \ManaPHP\Data\Relation\ManagerInterface

Type

\ManaPHP\Data\Relation\ManagerInterface

$alias

$alias : \ManaPHP\AliasInterface

Type

\ManaPHP\AliasInterface

$eventsManager

$eventsManager : \ManaPHP\Event\ManagerInterface

Type

\ManaPHP\Event\ManagerInterface

$logger

$logger : \ManaPHP\Logging\LoggerInterface

Type

\ManaPHP\Logging\LoggerInterface

$configure

$configure : \ManaPHP\Configuration\Configure

Type

\ManaPHP\Configuration\Configure

$settings

$settings : \ManaPHP\Configuration\SettingsInterface

Type

\ManaPHP\Configuration\SettingsInterface

$crypt

$crypt : \ManaPHP\Security\CryptInterface

Type

\ManaPHP\Security\CryptInterface

$identity

$identity : \ManaPHP\IdentityInterface

Type

\ManaPHP\IdentityInterface

$cache

$cache : \ManaPHP\Caching\CacheInterface

Type

\ManaPHP\Caching\CacheInterface

$httpClient

$httpClient : \ManaPHP\Http\ClientInterface

Type

\ManaPHP\Http\ClientInterface

$restClient

$restClient : \ManaPHP\Http\ClientInterface

Type

\ManaPHP\Http\ClientInterface

$db

$db : \ManaPHP\Data\DbInterface

Type

\ManaPHP\Data\DbInterface

$redisCache

$redisCache : \Redis|\ManaPHP\Data\RedisInterface

Type

\Redis|\ManaPHP\Data\RedisInterface

$redisDb

$redisDb : \Redis|\ManaPHP\Data\RedisInterface

Type

\Redis|\ManaPHP\Data\RedisInterface

$redisBroker

$redisBroker : \Redis|\ManaPHP\Data\RedisInterface

Type

\Redis|\ManaPHP\Data\RedisInterface

$mongodb

$mongodb : \ManaPHP\Data\MongodbInterface

Type

\ManaPHP\Data\MongodbInterface

$rabbitmq

$rabbitmq : \ManaPHP\Messaging\AmqpInterface

Type

\ManaPHP\Messaging\AmqpInterface

$elasticsearch

$elasticsearch : \Elasticsearch\Client

Type

\Elasticsearch\Client

$mailer

$mailer : \ManaPHP\Mailing\MailerInterface

Type

\ManaPHP\Mailing\MailerInterface

$bosClient

$bosClient : \ManaPHP\Bos\ClientInterface

Type

\ManaPHP\Bos\ClientInterface

$wspClient

$wspClient : \ManaPHP\Ws\Pushing\ClientInterface

Type

\ManaPHP\Ws\Pushing\ClientInterface

$coroutineManager

$coroutineManager : \ManaPHP\Coroutine\ManagerInterface

Type

\ManaPHP\Coroutine\ManagerInterface

$wsClient

$wsClient : \ManaPHP\Ws\ClientInterface

Type

\ManaPHP\Ws\ClientInterface

$pubSub

$pubSub : \ManaPHP\Messaging\PubSubInterface

Type

\ManaPHP\Messaging\PubSubInterface

$_context

$_context : \object

Type

\object

$_di

$_di : \ManaPHP\DiInterface

Type

\ManaPHP\DiInterface

$_table

$_table : string

Type

string

$_alias

$_alias : string

Type

string

$_fields

$_fields : array

Type

array

$_limit

$_limit : integer

Type

integer

$_offset

$_offset : integer

Type

integer

$_distinct

$_distinct : boolean

Type

boolean

$_model

$_model : \ManaPHP\Data\Model

Type

\ManaPHP\Data\Model

$_multiple

$_multiple : boolean

Type

boolean

$_with

$_with : array

Type

array

$_order

$_order : array

Type

array

$_group

$_group : array

Type

array

$_index

$_index : string|array|callable

Type

string|array|callable

$_aggregate

$_aggregate : array

Type

array

$_force_master

$_force_master : boolean

Type

boolean

$_shard_context

$_shard_context : array

Type

array

$_shard_strategy

$_shard_strategy : callable

Type

callable

$_object_id

$_object_id : integer

Type

integer

$_on

$_on : array<mixed,callable>

Type

array<mixed,callable>

$_injections

$_injections : array

Type

array

$_joins

$_joins : array

Type

array

$_conditions

$_conditions : array

Type

array

$_having

$_having : array

Type

array

$_for_update

$_for_update : boolean

Type

boolean

$_bind

$_bind : array

Type

array

$_sql

$_sql : string

Type

string

Methods

getIterator()

getIterator() 

jsonSerialize()

jsonSerialize() 

setModel()

setModel(\ManaPHP\Data\Model  $model) : static

Parameters

\ManaPHP\Data\Model $model

Returns

static

getModel()

getModel() : \ManaPHP\Data\Model|null

Returns

\ManaPHP\Data\Model|null

shard()

shard(callable  $strategy) : static

Parameters

callable $strategy

Returns

static

getShards()

getShards() : array

Returns

array

getUniqueShard()

getUniqueShard() : array

Returns

array

from()

from(string  $table, string  $alias = null) : static

Parameters

string $table
string $alias

Returns

static

distinct()

distinct(boolean  $distinct = true) : static

Sets SELECT DISTINCT / SELECT ALL flag

Parameters

boolean $distinct

Returns

static

search()

search(array  $filters) : static

Parameters

array $filters

=get_object_vars(new Model)

Returns

static

where()

where(array  $filters) : static

Appends a condition to the current conditions using a AND operator

Parameters

array $filters

=get_object_vars(new Model)

Returns

static

whereDateBetween()

whereDateBetween(string  $field, integer|string  $min, integer|string  $max) : static

Parameters

string $field

=key(get_object_vars(new Model))

integer|string $min
integer|string $max

Returns

static

groupBy()

groupBy(string|array  $groupBy) : static

Sets a GROUP BY clause

Parameters

string|array $groupBy

=get_object_vars(new Model) ?: key(get_object_vars(new Model))

Returns

static

orderBy()

orderBy(string|array  $orderBy) : static

Sets a ORDER BY condition clause

Parameters

string|array $orderBy

=get_object_vars(new Model) ?: key(get_object_vars(new Model)) ?: [$k=>SORT_ASC, $k=>SORT_DESC]

Returns

static

indexBy()

indexBy(callable|string|array  $indexBy) : static

Parameters

callable|string|array $indexBy

=key(get_object_vars(new Model))

Returns

static

limit()

limit(integer  $limit, integer  $offset = null) : static

Sets a LIMIT clause, optionally a offset clause

Parameters

integer $limit
integer $offset

Returns

static

with()

with(string|array  $with) : static

Parameters

string|array $with

Returns

static

page()

page(integer  $size = null, integer  $page = null) : static

Parameters

integer $size
integer $page

Returns

static

setFetchType()

setFetchType(boolean  $multiple) : static

Parameters

boolean $multiple

Returns

static

fetch()

fetch(boolean  $asArray = false) : array<mixed,\ManaPHP\Data\Model>|\ManaPHP\Data\Model|null|array|\ManaPHP\Data\Query\Row

Parameters

boolean $asArray

Returns

array<mixed,\ManaPHP\Data\Model>|\ManaPHP\Data\Model|null|array|\ManaPHP\Data\Query\Row

paginate()

paginate(integer  $size = null, integer  $page = null) : \ManaPHP\Data\Paginator

Parameters

integer $size
integer $page

Returns

\ManaPHP\Data\Paginator

forceUseMaster()

forceUseMaster(boolean  $forceUseMaster = true) : static

Parameters

boolean $forceUseMaster

Returns

static

first()

first() : array|null

Returns

array|null

get()

get() : array

Returns

array

all()

all() : array

Returns

array

value()

value(string  $field, mixed  $default = null) : mixed

Parameters

string $field

=key(get_object_vars(new Model))

mixed $default

Returns

mixed

sum()

sum(string  $field) : integer|float|null

Parameters

string $field

=key(get_object_vars(new Model))

Returns

integer|float|null

max()

max(string  $field) : integer|float|null

Parameters

string $field

=key(get_object_vars(new Model))

Returns

integer|float|null

min()

min(string  $field) : integer|float|null

Parameters

string $field

=key(get_object_vars(new Model))

Returns

integer|float|null

avg()

avg(string  $field) : float|null

Parameters

string $field

=key(get_object_vars(new Model))

Returns

float|null

options()

options(array  $options) : static

Parameters

array $options

Returns

static

when()

when(callable  $call) : static

Parameters

callable $call

Returns

static

whereDate()

whereDate(string  $field, string|integer  $date) : static

Parameters

string $field

=key(get_object_vars(new Model))

string|integer $date

Returns

static

whereMonth()

whereMonth(string  $field, string|integer  $date) : static

Parameters

string $field

=key(get_object_vars(new Model))

string|integer $date

Returns

static

whereYear()

whereYear(string  $field, string|integer  $date) : static

Parameters

string $field
string|integer $date

Returns

static

innerJoin()

innerJoin(string  $table, string  $condition = null, string  $alias = null) : static

Parameters

string $table
string $condition
string $alias

Returns

static

leftJoin()

leftJoin(string  $table, string  $condition = null, string  $alias = null) : static

Parameters

string $table
string $condition
string $alias

Returns

static

rightJoin()

rightJoin(string  $table, string  $condition = null, string  $alias = null) : static

Parameters

string $table
string $condition
string $alias

Returns

static

getInstance()

getInstance(string  $class, array  $params = array()) : mixed

Parameters

string $class
array $params

Returns

mixed

getShared()

getShared(string  $name) : mixed

Parameters

string $name

Returns

mixed

inject()

inject(string  $name, mixed  $target) : static

Parameters

string $name
mixed $target

Returns

static

__get()

__get(string  $name) : mixed

Magic method __get

Parameters

string $name

Returns

mixed

__set()

__set(string  $name, mixed  $value) : void

Parameters

string $name
mixed $value

__isset()

__isset(string  $name) : boolean

Parameters

string $name

Returns

boolean

attachEvent()

attachEvent(string  $event, callable  $handler, boolean  $appended = true) : static

Attach a listener to the events manager

Parameters

string $event
callable $handler
boolean $appended

Returns

static

detachEvent()

detachEvent(string  $event, callable  $handler) : static

Parameters

string $event
callable $handler

Returns

static

peekEvent()

peekEvent(string  $group, callable  $handler) : static

Parameters

string $group
callable $handler

Returns

static

fireEvent()

fireEvent(string  $event, mixed  $data = array(), mixed  $source = null) : void

Fires an event in the events manager causing that the active listeners will be notified about it

Parameters

string $event
mixed $data
mixed $source

on()

on(string  $event, callable  $handler) : static

Parameters

string $event
callable $handler

Returns

static

off()

off(string  $event = null, callable  $handler = null) : static

Parameters

string $event
callable $handler

Returns

static

emit()

emit(string  $event, array  $data = array()) : void

Parameters

string $event
array $data

__debugInfo()

__debugInfo() : array

Returns

array

dump()

dump() : array

Returns

array

toArray()

toArray() : array

Returns

array

setDb()

setDb(\ManaPHP\Data\DbInterface|string  $db) : static

Parameters

\ManaPHP\Data\DbInterface|string $db

Returns

static

select()

select(string|array  $fields) : static

Parameters

string|array $fields

Returns

static

join()

join(string  $table, string  $condition = null, string  $alias = null, string  $type = null) : static

Parameters

string $table
string $condition
string $alias
string $type

Returns

static

whereEq()

whereEq(string  $field, mixed  $value) : static

Parameters

string $field
mixed $value

Returns

static

whereCmp()

whereCmp(string  $field, string  $operator, mixed  $value) : static

Parameters

string $field
string $operator
mixed $value

Returns

static

whereMod()

whereMod(string  $field, integer  $divisor, integer  $remainder) : static

Parameters

string $field
integer $divisor
integer $remainder

Returns

static

whereExpr()

whereExpr(string  $expr, array  $bind = null) : static

Parameters

string $expr
array $bind

Returns

static

whereBetween()

whereBetween(string  $field, integer|float|string  $min, integer|float|string  $max) : static

Parameters

string $field
integer|float|string $min
integer|float|string $max

Returns

static

whereNotBetween()

whereNotBetween(string  $field, integer|float|string  $min, integer|float|string  $max) : static

Parameters

string $field
integer|float|string $min
integer|float|string $max

Returns

static

whereIn()

whereIn(string  $field, array  $values) : static

Parameters

string $field
array $values

Returns

static

whereRaw()

whereRaw(string  $filter, array  $bind = null) : static

Parameters

string $filter
array $bind

Returns

static

whereNotIn()

whereNotIn(string  $field, array  $values) : static

Parameters

string $field
array $values

Returns

static

whereInset()

whereInset(string  $field, string  $value) : static

Parameters

string $field
string $value

Returns

static

whereNotInset()

whereNotInset(string  $field, string  $value) : static

Parameters

string $field
string $value

Returns

static

whereLike()

whereLike(string|array  $fields, string  $like) : static

Parameters

string|array $fields
string $like

Returns

static

whereNotLike()

whereNotLike(string|array  $fields, string  $like) : static

Parameters

string|array $fields
string $like

Returns

static

whereContains()

whereContains(string|array  $fields, string  $value) : static

Parameters

string|array $fields
string $value

Returns

static

whereNotContains()

whereNotContains(string|array  $fields, string  $value) : static

Parameters

string|array $fields
string $value

Returns

static

whereStartsWith()

whereStartsWith(string|array  $fields, string  $value, integer  $length = null) : static

Parameters

string|array $fields
string $value
integer $length

Returns

static

whereNotStartsWith()

whereNotStartsWith(string|array  $fields, string  $value, integer  $length = null) : static

Parameters

string|array $fields
string $value
integer $length

Returns

static

whereEndsWith()

whereEndsWith(string|array  $fields, string  $value) : static

Parameters

string|array $fields
string $value

Returns

static

whereNotEndsWith()

whereNotEndsWith(string|array  $fields, string  $value) : static

Parameters

string|array $fields
string $value

Returns

static

whereRegex()

whereRegex(string  $field, string  $regex, string  $flags = '') : static

Parameters

string $field
string $regex
string $flags

Returns

static

whereNotRegex()

whereNotRegex(string  $field, string  $regex, string  $flags = '') : static

Parameters

string $field
string $regex
string $flags

Returns

static

whereNull()

whereNull(string  $field) : static

Parameters

string $field

Returns

static

whereNotNull()

whereNotNull(string  $field) : static

Parameters

string $field

Returns

static

where1v1()

where1v1(string  $id, string  $value) : static

Parameters

string $id
string $value

Returns

static

having()

having(string|array  $having, array  $bind = array()) : static

Parameters

string|array $having
array $bind

Returns

static

forUpdate()

forUpdate(boolean  $forUpdate = true) : static

Parameters

boolean $forUpdate

Returns

static

getSql()

getSql() : string

Returns

string

getBind()

getBind(string  $key = null) : array

Parameters

string $key

Returns

array

setBind()

setBind(array  $bind, boolean  $merge = true) : static

Parameters

array $bind
boolean $merge

Returns

static

execute()

execute() : array

Returns

array

aggregate()

aggregate(array  $expr) : array

Parameters

array $expr

Returns

array

count()

count(string  $field = '*') : integer

Parameters

string $field

Returns

integer

exists()

exists() : boolean

Returns

boolean

__toString()

__toString() : string

Returns

string

values()

values(string  $field) : array

Parameters

string $field

Returns

array

update()

update(array  $fieldValues) : integer

Parameters

array $fieldValues

Returns

integer

delete()

delete() : integer

Returns

integer

_createContext()

_createContext() : object

Returns

object

_buildGroup()

_buildGroup(array  $group) : string

Parameters

array $group

Returns

string

_buildOrder()

_buildOrder(array  $order) : string

Parameters

array $order

Returns

string

_buildSql()

_buildSql(\ManaPHP\Data\DbInterface  $db, string  $table, array  $joins) : string

Returns a SQL statement built based on the builder parameters

Parameters

\ManaPHP\Data\DbInterface $db
string $table
array $joins

Returns

string

_query()

_query(string  $db, string  $table) : array

Parameters

string $db
string $table

Returns

array

_buildAggregate()

_buildAggregate(array  $expr, array  $group) : string

Parameters

array $expr
array $group

Returns

string