webCOMAND

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

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");
}

Related

get(), query()