lithium\data\model\Query::__construct()
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.
This means that any information may be passed into the constructor may be used by the backend data source executing the query (or ignored, if support is not implemented). This is useful if, for example, you wish to extend a core data source and implement custom functionality.
Parameters
-
array
$config
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 ifmodel
is set.'alias'
string: Alias for the source. Unnecessary ifmodel
is set.'schema'
object: A schema model. Unnecessary ifmodel
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 thelimit
options.'page'
string: Convenience parameter for setting theoffset
:offset
=page
*limit
.'with'
array: Contain dependencies. Works only ifmodel
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 ifmodel
is set.'relationships'
array: Unnecessary ifmodel
is set.
Returns
voidSource
public function __construct(array $config = []) {
$defaults = [
'type' => 'read',
'mode' => null,
'model' => null,
'entity' => null,
'source' => null,
'alias' => null,
'fields' => [],
'conditions' => [],
'having' => [],
'group' => null,
'order' => null,
'limit' => null,
'offset' => null,
'page' => null,
'with' => [],
'joins' => [],
'data' => [],
'whitelist' => [],
'calculate' => null,
'schema' => null,
'comment' => null,
'map' => [],
'relationships' => []
];
$this->_autoConfig($config + $defaults, $this->_autoConfig);
$this->_autoInit($config);
}