Property | Type | Description | |
---|---|---|---|
$_alias | array | Count the number of identical models in a query for building unique aliases | |
$_autoConfig | array | Auto configuration properties. | |
$_built | string | Boolean indicate if the query is built or not | |
$_classes | array | Classes used by Query. | |
$_data | array | An array of data used in a write context. Only used if no binding object is present in the $_entity property. | |
$_entity | object | If a Query is bound to a Record or Document object (i.e. for a 'create' or 'update' query). | |
$_fields | array | The query's fields | |
$_initializers | array | Initialization methods on construct | |
$_map | array | Array containing mappings of relationship and field names, which allow database results to be mapped to the correct objects. | |
$_models | array | Map beetween generated aliases and corresponding models. | |
$_paths | array | Map beetween generated aliases and corresponding relation paths | |
$_schema | object | A query can be assigned its own custom schema object, using the schema() method. If this is not assigned, then the model associated with the query will be used to get the schema information. |
Method | Description | |
---|---|---|
__call ( string $method, array $params = [] ) : mixed | Gets or sets a custom query field which does not have an accessor method. | |
__construct ( array $config = [] ) : void | Constructor, which initializes the default values this object supports. Even though only a specific list of configuration parameters is available by default, the Query object uses the __call() method to implement automatic getters and setters for any arbitrary piece of data. | |
alias ( mixed $alias = true, string $relpath = null ) : string | Get or Set a unique alias for the query or a query's relation if $relpath is set. | |
applyStrategy ( |
Helper method used by export() which delegate the query generation to the data source. | |
calculate ( string $calculate = null ) : mixed | Accessor method for Query calculate values. | |
childs ( string $relpath = null, string $query = null ) : mixed | Get/set sub queries for the query. | |
comment ( string | null $comment = null ) : string | lithium\data\Query | Set and get method for current query's comment. | |
conditions ( string | array | null $conditions = null ) : string | |
Set or append to existing conditions, or get current conditions. | |
data ( array $data = [] ) : array | Set and get method for the query's record's data. | |
entity ( object &$entity = null ) : lithium\data\Query | |
Set and get method for the query's entity instance. | |
export ( |
Convert the query's properties to the data sources' syntax and return it as an array. | |
fields ( mixed $fields = null, boolean $overwrite = false ) : array | Set, get or reset fields option for query. | |
group ( string | array | null $group = null ) : array | null | lithium\data\Query | Set and get method for the Query group config setting. | |
having ( mixed $having = null ) : string | |
Set and get _having_. | |
joins ( string $name = null, object | string $join = null ) : mixed | Set and get the joins | |
limit ( integer | boolean $limit = null ) : integer | null | |
Set or get the limit for the amount of results to return. | |
map ( array $map = null ) : array | Generates a schema map of the query's result set, where the keys are aliases, and the values are arrays of field names. | |
model ( string | null $model = null ) : string | |
Set or get the associated model. | |
models ( |
Return the generated aliases mapped to their corresponding model | |
offset ( integer | null $offset = null ) : integer | lithium\data\Query | Set and get method for query's offset, i.e. which records to get | |
order ( array | string | null $order = null ) : array | lithium\data\Query | Set and get method for the query's order specification. | |
page ( integer | null $page = null ) : integer | lithium\data\Query | Set and get method for page, in relation to limit, of which records to get | |
paths ( |
Return the generated aliases mapped to their relation path | |
relationships ( string $relpath = null, array $config = null ) : mixed | Set and get the relationships. | |
respondsTo ( string $method, boolean $internal = false ) : boolean | Determines if a given method can be called. | |
schema ( $field = null ) |
Method | Description | |
---|---|---|
_entityConditions ( ) : array | Will return a find first condition on the associated model if a record is connected. | |
_exportData ( ) : array | Helper method used by export() to extract the data either from a bound entity, or from passed configuration, and filter it through a configured whitelist, if present. | |
_init ( ) |
public __construct ( array $config = [] ) : void | ||
$config | array | Available configuration options are: - `'type'` _string_: The type of the query (`read`, `create`, `update`, `delete`). - `'mode'` _string_: `JOIN` mode for a join query. - `'entity'` _object_: The base entity to query on. If set `'model'` is optionnal. - `'model'` _string_: The base model to query on. - `'source'` _string_: The name of the table/collection. Unnecessary if `model` is set. - `'alias'` _string_: Alias for the source. Unnecessary if `model` is set. - `'schema'` _object_: A schema model. Unnecessary if `model` is set. - `'fields'` _array_: The fields to retreive. - `'conditions'` _array_: The conditions of the queries - `'having'` _array_: The having conditions of the queries - `'group'` _string_: The group by parameter. - `'order'` _string_: The order by parameter. - `'limit'` _string_: The limit parameter. - `'offset'` _string_: The offset of the `limit` options. - `'page'` _string_: Convenience parameter for setting the `offset`: `offset` = `page` * `limit`. - `'with'` _array_: Contain dependencies. Works only if `model` is set. - `'joins'` _array_: Contain manual join dependencies. - `'data'` _array_: Datas for update queries. - `'whitelist'` _array_: Allowed fields for updating queries. - `'calculate'` _string_: Alias name of the count. - `'comment'` _string_: Comment for the query. - `'map'` _object_: Unnecessary if `model` is set. - `'relationships'` _array_: Unnecessary if `model` is set. |
return | void |
protected _entityConditions ( ) : array | ||
return | array | Returns an array in the following format: `([model's primary key'] => [that key set in the record])`. |
protected _exportData ( ) : array | ||
return | array |
public alias ( mixed $alias = true, string $relpath = null ) : string | ||
$alias | mixed | The value of the alias to set for the passed `$relpath`. For getting an alias value set alias to `true`. |
$relpath | string | A dotted relation name or `null` for identifying the query's model. |
return | string | An alias value or `null` for an unexisting `$relpath` alias. |
public applyStrategy ( |
||
$source | Instance of the data source to use for conversion. |
public conditions ( string | array | null $conditions = null ) : string | |
||
$conditions | string | array | null | Condition/s to append to existing conditions. Provide `null` to get current conditions. |
return | string | |
Either the currrent conditions when $conditions is `null` or the query itself when setting the conditions. |
public joins ( string $name = null, object | string $join = null ) : mixed | ||
$name | string | Optional name of join. Unless two parameters are passed, this parameter is regonized as `$join`. |
$join | object | string | A single query object or an array of query objects |
return | mixed | The joins array or a join array if `$name` is set. Returns `null` if a join doesn't exist. |
public limit ( integer | boolean $limit = null ) : integer | null | |
||
$limit | integer | boolean | An integer indicating the number of results to limit or `false` to employ no limit at all. Or `null` to retrieve the current limit. |
return | integer | null | |
Either the currrent limit when $limit is `null` or the query itself when setting the limit or providing `false`. |
public respondsTo ( string $method, boolean $internal = false ) : boolean | ||
$method | string | Name of the method. |
$internal | boolean | Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`. |
return | boolean | Returns `true` if the method can be called, `false` otherwise. |
protected array $_alias | ||
return | array |
protected array $_autoConfig | ||
return | array |
protected string $_built | ||
return | string |
protected array $_data | ||
return | array |
protected object $_entity | ||
return | object |
protected array $_initializers | ||
return | array |
protected array $_map | ||
return | array |
protected array $_models | ||
return | array |
protected array $_paths | ||
return | array |
protected object $_schema | ||
return | object |