ObjectQuery implements a template based object query.
This class provides the user with object templates on which query conditions may be set. Object templates are Node instances whose attribute values are used as conditions on the appropriate attributes. A value maybe a scalar or a Criteria instance. For example $authorTpl->setValue("name", Criteria::forValue("LIKE", "%ingo%") means searching for authors whose name contains 'ingo'. If only a scalar is given LIKE '%...' is assumed.
A value condition of a template is joined with the preceeding conditions using the combine operator (Criteria::OPERATOR_AND, Criteria::OPERATOR_OR) given in the Criteria assigned to the template value. The set of conditions of a template is preceded by the operator (Criteria::OPERATOR_AND, Criteria::OPERATOR_OR) given in the ObjectQuery::PROPERTY_COMBINE_OPERATOR property (default: Criteria::OPERATOR_AND) of the template (see ObjectQuery::getObjectTemplate()).
Multiple conditions for one value are built using different object templates of the same type. Conditions sets of different object templates are grouped with brackets if they are passed to ObjectQuery::makeGroup().
- : If there are two object templates of the same type as the query type linked in a parent child relation, than the nodes that are selected depend on the attributes of the first object template that is received by ObjectQuery::getObjectTemplate.
: The query does not search in objects, that are created inside the current transaction.
The following example shows the usage:
$query = new ObjectQuery('Author');
$authorTpl1 = $query->getObjectTemplate('Author');
$authorTpl1->setValue("email", "LIKE '%wemove%'");
$recipeTpl1 = $query->getObjectTemplate('Recipe');
$recipeTpl1->setValue("created", ">= '2004-01-01'");
$recipeTpl2 = $query->getObjectTemplate('Recipe');
$recipeTpl2->setValue("created", "< '2005-01-01'");
$recipeTpl3 = $query->getObjectTemplate('Recipe');
$recipeTpl4->setValue("portions", "= 4");
- There are some limitations when using this class:
- This class works only with Nodes as PersistentObjects
- This class only works for Nodes mapped by RDBMapper subclasses.
- All objects have to reside in the same datastore (the connection is taken from the first mapper)
- Since the query values are set together with the operator in a single string, they must be converted to data store format already
- ingo herwig ingo@.firstname.lastname@example.org@email@example.com
Definition at line 105 of file ObjectQuery.php.