- ⌂ query
- Properties
- Methods
query Class
The query class provides a fluent interface to assemble, modify and execute cPath, cQL and cQuery to retrieve an Object, collection or row set from a webCOMAND repository.
Example
$repo = comand::repo();
$name = 'Jane';
$age = 18;
// A. query contacts using a Query String with bindings
$contacts = $repo->get('SELECT OID, Name FROM Contact WHERE Name=? AND Age>?',
['bind'=>[$name, $age]]);
foreach($contacts as $contact) {
print($contact->Name . " (OID " . $contact->OID . ")\n");
}
// B. query contacts using a chained Query Object with bindings
$contacts = $repo->query()
->select('OID, Name')
->from('Contact')
->where('Name=? AND Age>?')
->bind([$name, $age])
->get();
foreach($contacts as $contact) {
print($contact->Name . " (OID " . $contact->OID . ")\n");
}
// C. query contacts using a Query object with named bindings
$query = $repo->query()->from('Contact');
$query->where('Name=:name AND Age>:age')
->bind(['name'=>$name, 'age'=>$age]);
$contacts = $query->get_rows();
foreach($contacts as $contact) {
print($contact['Name'] . " (OID " . $contact['OID'] . ")\n");
}
Class Definition
| Namespace | io_comand_repo |
| Extends | nothing |
| Implements | nothing |
Properties
Query object properties are primarily used to access information about the assembled query.
select
cQL Array representation of SELECT clause.
from
cQL Array representation of FROM clause.
in
Folder or other object that implements Children interface, as referenced in the IN clause. If an IN clause contains suffix keywords, the in property will be an array of all Folders represented after they are evaluated.
where
cQL Array representation of WHERE clause.
group_by
cQL Array representation of GROUP BY clause.
order_by
cQL Array representation of ORDER BY clause.
limit_offset
Integer representation of offset element of the LIMIT clause.
limit_count
Integer representation of the count element of the LIMIT clause.
Methods
Query & Execution Methods
- Constructor - Start preparing a query that can be modified with chained or subsequent query condition methods (see next section below), and then ultimately executed with one of the following methods.
- get() - Get results as a collection of zero or more objects.
- get_first() - Get the first result as a single cObject, or NULL if no result.
- get_rows() - Get results as a row set of zero or more rows.
- get_row() - Get the first result as an associative array, or NULL if no result.
Query Building (Clause Modifiers)
Methods used to programmatically assemble clauses in a fluent chain.
SELECT
The following methods determine which object properties to return when the query is performed.
- select()
- clear_select()
- set_full_select()
- straight_join()
- all_variants()
- distinct()
FROM
- from()
Context Modifiers
The following methods are used to modify a context of the query, such as which folder, dimensions, point in time or workflow state to query against.
- in()
- with()
- as_of()
- workflow()
WHERE
- where()
- and_where()
- or_where()
- where_null()
- and_where_null()
- or_where_null()
- where_in()
- where_not_in()
- and_where_not_in()
- or_where_in()
- or_where_not_in()
- where_between()
- where_not_between()
- and_where_between()
- and_where_not_between()
- or_where_between()
- or_where_not_between()
- clear_where()
LIKE
- like()
- not_like()
- and_like()
- and_not_like()
- or_like()
- or_not_like()
ILIKE (Case-Insensitive LIKE)
- ilike()
- not_ilike()
- and_ilike()
- and_not_ilike()
- or_ilike()
- or_not_ilike()
RLIKE
- rlike()
- not_rlike()
- and_rlike()
- and_not_rlike()
- or_rlike()
- or_not_rlike()
RegExp (Regular Expression)
- regexp()
- not_regexp()
- and_regexp()
- and_not_regexp()
- or_regexp()
- or_not_regexp()
GROUP BY
- group_by()
- clear_group_by()
- group_start()
- not_group_start()
- and_group_start()
- and_not_group_start()
- or_group_start()
- or_not_group_start()
- group_end()
HAVING
- having()
- clear_having()
- having_group_start()
- not_having_group_start()
- and_having_group_start()
- and_not_having_group_start()
- or_having_group_start()
- or_not_having_group_start()
- having_group_end()
ORDER BY
- order_by()
- clear_order_by()
LIMIT
- limit()
- limit_again()
BIND
- bind()
- clear_bind()
Query Access Methods
The following methods are used to access query information.
- combine()
- is_aggregate()
- is_mutation()
- get_type()
- repo()
- get_stats()
- execute()
- checksum()
- get_select_expressions()
- get_select_fieldnames()
- get_select_info()
Write & Mutation Operations
- insert()
- set()
- values()
- action_mod()
- update()
- delete()
- approve()
- save()
- store()
- restore()
- revert()
Utility & Debugging
- __toString() - Convert the query object to a cQL string.
- get_array_format() - Returns the raw cQL Array representation.
- get_cache_key() - Returns a unique serialized key for query caching.
webCOMAND Docs