webCOMAND

collection::get_row()

Query a collection and return the first matching object's field values in an associative array, like a row in a row set.

Prototype

array get_row(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 (?), 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

An associative array of field values of the first object to match the query, otherwise NULL.

Example

$contacts = $repo->get_row("SELECT * FROM Contact WHERE Name='John'");
echo($contact['Name'] . " - " . $contact['Phone'] . "\n");