webCOMAND

query Class

  • Namespace: io_comand_repo
  • Extends: nothing
  • Implements: nothing

The query class provides methods to assemble and process cPath, cQL and cQuery to retrieve an Object, collection or row set from a repository based on specific criteria.

Queries are expressed in one of the Query Formats:

For an introduction to the query class, see PHP API Basics: Query a repository.
For more in-depth information about API queries, see COMAND API Queries.

Example

$name = 'Jane';
$age = 18;

// perform a simple query that uses ? placeholders
$results = $repo->query()
    ->from('Contact')
    ->where('Name=? AND Age>?')
    ->bind([$name, $age])
    ->get();

// iterate through the collection results
foreach($result as $contact) {
    print($contact->Name . ": " . $contact->Phone . "\n");
}

// start building a similar query
$query = $repo->query()->from('Contact');

// add to the query using named placeholders
$query->where('Name=:name AND Age>:age')
    ->bind(['name'=>$name, 'age'=>$age]);

// get the results as a row set
$results = $query->get_rows();

// iterate through the row set results
foreach($result as $contact) {
    print($contact['Name'] . ": " . $contact['Phone'] . "\n");
}

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

The following methods still need to be documented.
  • __toString()

 

  • where_between()
  • where_not_between()
  • or_where_between()
  • or_where_not_between()

 

  • like()
  • not_like()
  • or_like()
  • or_not_like()

 

  • ilike()
  • not_ilike()
  • or_ilike()
  • or_not_ilike()

 

  • rlike()
  • not_rlike()
  • or_rlike()
  • or_not_rlike()

 

  • group_start()
  • not_group_start()
  • or_group_start()
  • or_not_group_start()
  • group_end()
  • group_by()
  • set_full_select()
  • straight_join()
  • with()
  • having()
  • and_having()
  • or_having()
  • group start
  • group end
  • init()
  • apply_options()
  • get_options()
  • get_array()
  • get_storage_array()
  • combine()
  • checksum()
  • is_aggregate()
  • get_all_field_strings()
  • get_selected_field_strings()
  • get_select_expressions()
  • get_select_fieldnames()