- ⌂ repo
- Methods
- Constructor
- execute()
- get()
- get_content_type()
- get_first()
- get_object()
- get_object_by_id()
- get_object_by_oid()
- get_object_by_doid()
- get_object_by_uuid()
- get_objects_by_id()
- get_objects_by_oid()
- get_objects_by_doid()
- get_objects_by_uuid()
- get_root()
- get_row()
- get_rows()
- get_system_property()
- log_alert()
- log_critical()
- log_to_file()
- log_to_html()
- new_collection()
- new_object()
- peek_user()
- pop_user()
- push_super_user()
- push_user()
- query()
- supports_dimensions()
- switch_user()
- uninit()
- with()
repo::execute()
Execute a cQL query on the repository and return a collection of objects.
New to COMAND queries? Check out the COMAND API Queries Tutorial.
Prototype
collection execute(string $cql, array $options = [])
Parameters
- query - cQL string or cQL Array
- options - See query Constructor options.
Return
A collection of objects that match the query, including SELECT, INSERT and DELETE queries
For information about query performance and object caching, see Repository Object Cache.
Examples
cQL Example
$contacts = $repo->execute("SELECT * FROM Contact WHERE Name='John'");
foreach( $contacts as $contact ) {
echo( $contact->Name . " - " . $contact->Phone . "\n" );
}
? Binding Example
$name = 'John';
$contacts = $repo->execute("SELECT Name, Phone FROM Contact WHERE Name=?",
['bind'=>[$name]]);
foreach( $contacts as $contact ) {
echo( $contact->Name . " - " . $contact->Phone . "\n" );
}
:Name Binding Example
$name = 'John';
$contacts = $repo->execute("SELECT Name, Phone FROM Contact WHERE Name=:Name",
['bind'=>['Name'=>$name]]);
foreach($contacts as $contact) {
echo($contact->Name . " - " . $contact->Phone . "\n");
}