Framework
3.9
|
Query provides an object-oriented interface for database queries. More...
Public Member Functions | |
__construct ($class, $constraints="") | |
Creates a new Query object. More... | |
page ($page, $size) | |
Sets the page number and size for constraining the result set by page. More... | |
tableAlias ($alias) | |
Sometimes when you are creating abonimable SQL constraints you might need to refer back to the main object table by a specific alias. More... | |
exists () | |
Return true if the query matches one or more rows in the database. More... | |
execute () | |
Executes the query and returns an array of DataItems containing the results (the class of items returned is as specified in the Query constructor). More... | |
executeSingle () | |
Executes the query and returns a singleton result row. More... | |
executeValue ($func) | |
Query the database to calculate an aggregate value. More... | |
count () | |
Return the count of matching results. More... | |
Public Member Functions inherited from AbstractQuery | |
constraints ($constraints) | |
Sets the constraint clause for the Query. More... | |
filter ($filter) | |
Sets a filter to constrain the fields retrieved when the query is executed. More... | |
params ($params) | |
Sets the bound parameters array. More... | |
bind () | |
Binds placeholders to parameter values. More... | |
Static Public Member Functions | |
static | create ($class, $constraints="") |
Static factory method to create a new Query. More... | |
Public Attributes | |
$page | |
$size | |
$tableAlias | |
Public Attributes inherited from AbstractQuery | |
$class | |
$constraints | |
$filter | |
$params | |
Query provides an object-oriented interface for database queries.
By instantiating Query objects you can specify a full or partial set of criteria and parameters, and then subsequently execute the query to retrieve the results. You can pass around the constructed Query object and execute it multiple times, allowing for lazy evaluation and other performance enhancing tricks.
Query::__construct | ( | $class, | |
$constraints = "" |
|||
) |
Creates a new Query object.
string | $class | the DataItem class to be queried |
string | $constraints | [optional] constraint clause for the query |
Reimplemented from AbstractQuery.
Definition at line 137 of file query.inc.
Query::count | ( | ) |
Return the count of matching results.
Definition at line 347 of file query.inc.
|
static |
Query::execute | ( | ) |
Executes the query and returns an array of DataItems containing the results (the class of items returned is as specified in the Query constructor).
Reimplemented from AbstractQuery.
Definition at line 214 of file query.inc.
Query::executeSingle | ( | ) |
Executes the query and returns a singleton result row.
If no results match then a DataNotFoundException is thrown. If more than one row matches, then a DataItemException is thrown.
Definition at line 286 of file query.inc.
Query::executeValue | ( | $func | ) |
Query the database to calculate an aggregate value.
The database table associated with the specified class is used as the source for the data.
string | $func | the value or function to retrieve |
Query::exists | ( | ) |
Query::page | ( | $page, | |
$size | |||
) |
Query::tableAlias | ( | $alias | ) |
Sometimes when you are creating abonimable SQL constraints you might need to refer back to the main object table by a specific alias.
In those cases, set the table alias for the main object using this message.
$alias | String the table alias name |