Narrow your query results by specifying a set of criteria to select on. Where clauses can be used with the SELECT, UPDATE, and DELETE query types.
where(array $filters)
Arguments
$filters: array
A collection of filters to apply to a query. The basic format is column[operator] => operand. The operand can be a string, number or an array containing multiple strings/numbers.
Supported Operators
[=]: Equal
[>]: Greater Than
[<]: Less Than
[<>]: Between
[in]: In
[~]: Like
[null]: Is Null
[!=]: Not Equal
[>=]: Greater Than or Equal to
[<=]: Less Than or Equal to
[><]: Not Between
[!in]: Not In
[!~]: Not Like
[!null]: Is Not Null
Sample Usage
try{
// Select a user whose email address is [email protected]
$s = $squibble->select('users', [
'id',
'first_name',
'last_name',
'email_address'
])->where([
'email_address[=]' => '[email protected]'
]);
// collect() return an array of the result sets. This is the
// same as PDO $query->fetchAll(PDO::FETCH_ASSOC)
$user = $s->collect();
}catch(PDOException $e){
echo "Error, {$e->getCode()}, {$e->getMessage()}";
}catch(Exception $e){
echo "Error, {$e->getCode()}, {$e->getMessage()}";
}