- ⌂ collection
- Methods
collection::get_first()
Perform a query on a collection and return the first matching object.
Prototype
object get_first(mixed $query, array $options = [])
Parameters
- query - cPath string, cQL string, Query Object or cQL Array.
- 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 Object to match the query, otherwise NULL.
Example
$contacts = $collection->get_first("SELECT Name, Phone FROM Contact WHERE Name='John'");
echo($contact->Name . " - " . $contact->Phone . "\n");