limb3_2007_3:en:architecture:criteria
Criteria
Criteria is a group of classes that allows you to build complex conditions for SQL queries using nice OO interface. The initial conception was adopted from Propel and later was a bit simplified.
UML Static Structure
Criteria classes
All criteria classes are children of lmbSQLBaseCriteria class that implements basic functionality to allow a composition of criteria.
| Class name | Description |
|---|---|
| lmbSQLRawCriteria | Allows to insert a condition into SQL query as is. |
| lmbSQLFieldCriteria | Allows to insert a condition on some field. |
| lmbSQLTableFieldCriteria | A child class of lmbSQLFieldCriteria. Requeres explicit table name. |
| SQLFielBetweenCriteria | Allows to insert between conditions into SQL query. |
| lmbSQLFalseCriteria | Critetia that is never passed. |
| lmbSQLTrueCriteria | Criteria that is always passed. |
Criteria usage
Criteria are commonly used with lmbSelectQuery class to insert conditions into %where% and %having% placeholders.
Here is how lmbSQLFieldCriteria is used:
$query->addCondition(newSQLFieldCriteria('name', '%'.$name.'%', lmbSQLFieldCriteria :: LIKE));
It's possible to combine criteria objects:
$criteria = new lmbSQLTableFieldCriteria('ingredient.name', '%'.$name.'%', lmbSQLFieldCriteria :: LIKE); $new_criteria = new lmbSQLTableFieldCriteria('ingredient.name', '%'.$name.'%', lmbSQLFieldCriteria :: LIKE); $criteria->addOr($new_criteria); $criteria->addAnd(new SQLFielBetweenCriteria('value', 10, 20)); $query->addCondition($criteria);
limb3_2007_3/en/architecture/criteria.txt · Последнее изменение: 2010/11/10 10:02 — 127.0.0.1


Обсуждение