Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
documentation:rack:reference:models [2018/05/26 15:34] – Martijn Luinstra | documentation:rack:reference:models [2019/05/10 17:57] – [Functions] Martijn Luinstra |
---|
* **isnull**: Tests if the field value is ''NULL'' (if <php>'field__isnull'=>true</php>) or not ''NULL'' (if <php>'field__isnull'=>false</php>). | * **isnull**: Tests if the field value is ''NULL'' (if <php>'field__isnull'=>true</php>) or not ''NULL'' (if <php>'field__isnull'=>false</php>). |
| |
If the comparison function is omitted (<php>'field' => $value</php>), the default of **eq** is used. | If the comparison function is omitted (<php>'field' => $value</php>), the default of **eq** is used. |
| |
| The <php>get</php> function also supports custom ordering by passing a list of field names. Descending ordering can be achieved by adding a minus in front of the field name. The following example will order first by study and then by birthdate in descending ordering: <php>['study', '-birthdate']</php>. |
===== Functions ===== | ===== Functions ===== |
| |
* <php>protected query($query, array $input_parameters=[])</php> Expects a query and input parameters that that can be used for [[http://php.net/manual/en/pdo.prepare.php|PDO prepared statements]]. | * <php>protected query($query, array $input_parameters=[])</php> Expects a query and input parameters that that can be used for [[http://php.net/manual/en/pdo.prepare.php|PDO prepared statements]]. |
* <php>protected query_first($query, array $input_parameters=[])</php> Same as <php>query</php>, but returns only the first result. | * <php>protected query_first($query, array $input_parameters=[])</php> Same as <php>query</php>, but returns only the first result. |
* <php>get(array $conditions=[], $get_first=false)</php> | * <php>get(array $conditions=[], array $order=[], $get_first=false)</php> |
* <php>get_by_id($id, $field='id')</php> | * <php>get_by_id($id, $field='id')</php> |
* <php>create(array $values)</php> | * <php>create(array $values)</php> Returns inserted ID. |
* <php>update(array $data, array $conditions=[])</php> Use with caution! | * <php>update(array $data, array $conditions=[])</php> Use with caution! |
* <php>update_by_id($id, array $data, $field='id')</php> | * <php>update_by_id($id, array $data, $field='id')</php> |