You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nik-os edited this page Sep 19, 2014
·
2 revisions
We create class \samson\activerecord\dbQuery for writing database queries. dbQuery() is shortcut for receiving \samson\activerecord\dbQuery object instance.
Functions
cond([attribute], [value], [relation] ) - add condition to query
[atribute] - attribute name in the search term
[value] - attribute value in the search term
[relation] - type of relations between the arguments of conditional group of the query to the database. Constatnt of class \samson\activerecord\dbRelation. Default - dbRelation::EQUAL;
exec() - execute request to DB and return array of query result. If we set parametr
Function returns ```true``` or ```false``` dependent on result of the query and set to ```$result``` query result.
It usefull in ```if``` constructions, such as
$result = array();
if (dbQuery('tableName')->exec($result))
{
//doing something with query result
}
* ```first()``` - doing the same as ```exec()```, but it return the first record from query result.
* ```order_by([attribute], [direction])``` - add sort parametr to request
* ```group_by([attribute])``` - add ```GROUP BY``` to request
* ```fields()``` -
* ```join()``` -