webCOMAND

repo::get_first()

Perform a query and return the first matching object.

New to COMAND queries?  Check out the COMAND API Queries Tutorial.

Prototype

cObject get_first(mixed $query, array $options = [])

Parameters

  • query - Query Array, Query Object or cQL string.
  • options
    • bind - Array of variables to bind to the query.  If the binding is a question mark (ie. ?), the array index is an index to the question mark (first question mark is represented by index zero, etc.).  If the binding is a named binding (ie. :Name), the array index is the binding name.

Return

The first cObject to match the query, otherwise NULL.

Example

$contacts = $repo->get_first("SELECT Name, Phone FROM Contact WHERE Name='John'");
echo($contact->Name . " - " . $contact->Phone . "\n");

Related

get(), get_row(), query::get_first()