wCMF
3.6
|
Public Member Functions | |
ObjectQuery ($type) | |
& | getObjectTemplate ($type, $preOperator=QUERYOP_AND, $interOperator=QUERYOP_AND) |
registerObjectTemplate (&$template, $preOperator=QUERYOP_AND, $interOperator=QUERYOP_AND) | |
makeGroup ($templates, $preOperator=QUERYOP_AND, $interOperator=QUERYOP_OR) | |
escapeValue ($value) | |
execute ($buildDepth, $orderby=null, &$pagingInfo, $attribs=null) | |
executeString ($type, $query, $buildDepth, $orderby=null, &$pagingInfo) | |
toString ($buildDepth=BUILDDEPTH_SINGLE, $attribs=null) | |
buildQuery ($buildDepth, $attribs=null) | |
processObjectTemplate (&$tpl, &$tableArray, &$conditionStr, &$relationArray) | |
getTableName (&$tpl, $asAliasString=false) | |
getRelationCondition (&$parentTpl, &$childTpl) | |
getOrderby ($type, $query, $orderby) | |
makeConditionStr (&$node, $valueName, $dataType, $operator) | |
& | getConnection ($type) |
& | getMapper (&$node) |
checkMapper (&$mapper) | |
getId () | |
valueChanged (&$object, $name, $type, $oldValue, $newValue) | |
propertyChanged (&$object, $name, $oldValue, $newValue) | |
stateChanged (&$object, $oldValue, $newValue) | |
Public Member Functions inherited from ChangeListener | |
getId () | |
valueChanged (&$object, $name, $type, $oldValue, $newValue) | |
propertyChanged (&$object, $name, $oldValue, $newValue) | |
stateChanged (&$object, $oldValue, $newValue) | |
Public Attributes | |
$_id = '' | |
$_typeNode = null | |
$_root = null | |
$_conditions = array() | |
$_groups = array() | |
$_groupedOIDs = array() | |
$_query = '' | |
ObjectQuery is the base class for object queries. 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 inludes the operator to be applied to it. For example $authorTpl->setValue("name", "LIKE '%ingo%'") means searching for authors whose name contains 'ingo'. Operator and value should be separated by a space. If no operator is given LIKE '%...' is assumed.
All value conditions of one template are joined with the same operator ('AND', 'OR') given in the "inter_operator" (DATATYPE_IGNORE) value of the template. The set of conditions of a template is preceded by the operator ('AND', 'OR', 'NOT') given in the "pre_operator" (DATATYPE_IGNORE) value (default: '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().
The following example shows the usage:
Definition at line 117 of file class.ObjectQuery.php.
ObjectQuery::ObjectQuery | ( | $type | ) |
Constructor.
type | The type to search for. |
Definition at line 131 of file class.ObjectQuery.php.
References BUILDDEPTH_SINGLE, and PersistenceFacade\getInstance().
& ObjectQuery::getObjectTemplate | ( | $type, | |
$preOperator = QUERYOP_AND , |
|||
$interOperator = QUERYOP_AND |
|||
) |
Get an object template for a given type.
type | The type to query for |
preOperator | One of the QUERYOP constants that precedes the conditions described in the template [default: QUERYOP_AND] |
interOperator | One of the QUERYOP constants that is used to join the conditions described in the template [default: QUERYOP_AND] |
Definition at line 146 of file class.ObjectQuery.php.
References BUILDDEPTH_SINGLE, DATATYPE_IGNORE, and PersistenceFacade\getInstance().
ObjectQuery::registerObjectTemplate | ( | & | $template, |
$preOperator = QUERYOP_AND , |
|||
$interOperator = QUERYOP_AND |
|||
) |
Register an object template at the query.
template | A reference to the template to register (must be an instance of PersistentObject) |
preOperator | One of the QUERYOP constants that precedes the conditions described in the template [default: QUERYOP_AND] |
interOperator | One of the QUERYOP constants that is used to join the conditions described in the template [default: QUERYOP_AND] |
Definition at line 162 of file class.ObjectQuery.php.
References DATATYPE_ATTRIBUTE, DATATYPE_IGNORE, PersistenceFacade\decomposeOID(), getMapper(), and PersistenceFacade\isDummyId().
ObjectQuery::makeGroup | ( | $templates, | |
$preOperator = QUERYOP_AND , |
|||
$interOperator = QUERYOP_OR |
|||
) |
Group different templates together to realize brackets in the query.
templates | An array of references to the templates contained in the group |
preOperator | One of the QUERYOP constants that precedes the group [default: QUERYOP_AND] |
interOperator | One of the QUERYOP constants that is used to join the conditions inside the group [default: QUERYOP_OR] |
Definition at line 195 of file class.ObjectQuery.php.
References $_groupedOIDs, Message\get(), and WCMFException\throwEx().
ObjectQuery::escapeValue | ( | $value | ) |
Escape a value for using it in a query.
value | The value. |
Definition at line 212 of file class.ObjectQuery.php.
ObjectQuery::execute | ( | $buildDepth, | |
$orderby = null , |
|||
& | $pagingInfo, | ||
$attribs = null |
|||
) |
Execute the object query
buildDepth | One of the BUILDDEPTH constants or a number describing the number of generations to load (except BUILDDEPTH_REQUIRED) or false if only oids should be returned |
orderby | An array holding names of attributes to ORDER by (maybe null). [default: null] |
pagingInfo | A reference paging info instance (optional, default null does not work in PHP4). |
attribs | An array of attributes to load (null to load all, if buildDepth != false). [default: null] |
Definition at line 226 of file class.ObjectQuery.php.
References $_query, buildQuery(), and executeString().
ObjectQuery::executeString | ( | $type, | |
$query, | |||
$buildDepth, | |||
$orderby = null , |
|||
& | $pagingInfo | ||
) |
Execute a serialized object query
type | The type to query |
query | The serialized query as string (as provided by ObjectQuery::toString) |
buildDepth | One of the BUILDDEPTH constants or a number describing the number of generations to load (except BUILDDEPTH_REQUIRED) or false if only oids should be returned |
orderby | An array holding names of attributes to ORDER by (maybe null). [default: null] |
pagingInfo | A reference paging info instance (optional, default null does not work in PHP4). |
Definition at line 244 of file class.ObjectQuery.php.
References BUILDDEPTH_SINGLE, PersistenceFacade\getInstance(), getMapper(), and getOrderby().
Referenced by StringQuery\execute(), execute(), AsyncPagingController\getObjects(), and SortController\sortAll().
ObjectQuery::toString | ( | $buildDepth = BUILDDEPTH_SINGLE , |
|
$attribs = null |
|||
) |
Get the query serialized to a string.
buildDepth |
attribs | An array of attributes to load (null to load all, if buildDepth != false). [default: null] |
Definition at line 285 of file class.ObjectQuery.php.
References buildQuery().
ObjectQuery::buildQuery | ( | $buildDepth, | |
$attribs = null |
|||
) |
Build the query
buildDepth |
attribs | An array of attributes to load (null to load all, if buildDepth != false). [default: null] |
Definition at line 295 of file class.ObjectQuery.php.
References $_groupedOIDs, DATATYPE_IGNORE, getMapper(), getTableName(), and processObjectTemplate().
Referenced by execute(), and toString().
ObjectQuery::processObjectTemplate | ( | & | $tpl, |
& | $tableArray, | ||
& | $conditionStr, | ||
& | $relationArray | ||
) |
Process an object template
tpl | The object template |
tableArray | An array of table names, where the tablename of the templates will be added |
conditionStr | A string of conditions, where the conditions described in the template will be added |
relationArray | An array of relation strings, where the relations of the template will be added |
Definition at line 377 of file class.ObjectQuery.php.
References DATATYPE_IGNORE, getRelationCondition(), and getTableName().
Referenced by buildQuery().
ObjectQuery::getTableName | ( | & | $tpl, |
$asAliasString = false |
|||
) |
Get the table name for the template.
tpl | The object template |
asAliasString | Return the table name in the form 'table as alias' [default: false] |
Definition at line 407 of file class.ObjectQuery.php.
References DATATYPE_IGNORE, and getMapper().
Referenced by StringQuery\buildQuery(), buildQuery(), getRelationCondition(), makeConditionStr(), and processObjectTemplate().
ObjectQuery::getRelationCondition | ( | & | $parentTpl, |
& | $childTpl | ||
) |
Get the relation condition between a parent and a child node.
parentTpl | The parent template node |
childTpl | The child template node |
Definition at line 444 of file class.ObjectQuery.php.
References getMapper(), and getTableName().
Referenced by StringQuery\buildQuery(), and processObjectTemplate().
ObjectQuery::getOrderby | ( | $type, | |
$query, | |||
$orderby | |||
) |
Get the order by string from given array of attribute names. If the orderby parameter is null, the default order is taken.
type | The node type to get the order by for |
query | The query to set the order by on |
orderby | Array of attribute names |
Definition at line 465 of file class.ObjectQuery.php.
References checkMapper(), and PersistenceFacade\getInstance().
Referenced by executeString().
ObjectQuery::makeConditionStr | ( | & | $node, |
$valueName, | |||
$dataType, | |||
$operator | |||
) |
Build a condition string from an object template. Used as a callback for a NodeProcessor. Adds each value condition to the "query_condition" value (DATATYPE_IGNORE)
node | A reference to the Node the holds the value (the template) |
valueName | The name of the value |
dataType | The dataType of the value |
operator | The operator to connect the value conditions with |
Definition at line 502 of file class.ObjectQuery.php.
References DATATYPE_IGNORE, getMapper(), getTableName(), and QUERYOP_AND.
& ObjectQuery::getConnection | ( | $type | ) |
Get the database connection of the given node type.
type | The node type to get the connection from connection |
Definition at line 555 of file class.ObjectQuery.php.
References PersistenceFacade\getInstance().
& ObjectQuery::getMapper | ( | & | $node | ) |
Get the mapper for a Node and check if it is a supported one.
node | A reference to the Node to get the mapper for |
Definition at line 567 of file class.ObjectQuery.php.
References checkMapper().
Referenced by StringQuery\buildQuery(), buildQuery(), StringQuery\execute(), executeString(), getRelationCondition(), getTableName(), makeConditionStr(), StringQuery\mapToDatabase(), and registerObjectTemplate().
ObjectQuery::checkMapper | ( | & | $mapper | ) |
Check if a mapper is a supported one.
mapper | A reference to the PersistenceMapper |
Definition at line 582 of file class.ObjectQuery.php.
References Message\get(), and WCMFException\throwEx().
Referenced by getMapper(), and getOrderby().
ObjectQuery::getId | ( | ) |
ChangeListener interface implementation
Definition at line 599 of file class.ObjectQuery.php.
References $_id.
ObjectQuery::valueChanged | ( | & | $object, |
$name, | |||
$type, | |||
$oldValue, | |||
$newValue | |||
) |
Definition at line 606 of file class.ObjectQuery.php.
References $GLOBALS, and DATATYPE_IGNORE.
ObjectQuery::propertyChanged | ( | & | $object, |
$name, | |||
$oldValue, | |||
$newValue | |||
) |
Definition at line 623 of file class.ObjectQuery.php.
ObjectQuery::stateChanged | ( | & | $object, |
$oldValue, | |||
$newValue | |||
) |
Definition at line 627 of file class.ObjectQuery.php.
ObjectQuery::$_id = '' |
Definition at line 119 of file class.ObjectQuery.php.
Referenced by getId().
ObjectQuery::$_typeNode = null |
Definition at line 120 of file class.ObjectQuery.php.
ObjectQuery::$_root = null |
Definition at line 121 of file class.ObjectQuery.php.
ObjectQuery::$_conditions = array() |
Definition at line 122 of file class.ObjectQuery.php.
ObjectQuery::$_groups = array() |
Definition at line 123 of file class.ObjectQuery.php.
ObjectQuery::$_groupedOIDs = array() |
Definition at line 124 of file class.ObjectQuery.php.
Referenced by buildQuery(), and makeGroup().
ObjectQuery::$_query = '' |
Definition at line 125 of file class.ObjectQuery.php.
Referenced by execute().