public _whereIn ( string $Field, array $Values, string $Op = 'in', string $Escape = true ) : Gdn_SQLDriver | ||
$Field | string | The field to search in for $Values. |
$Values | array | An array of values to look for in $Field. |
$Op | string | Either 'in' or 'not in' for the respective operation. |
$Escape | string | Whether or not to escape the items in $Values. clause. |
Результат | Gdn_SQLDriver | $this |
public function _whereIn($Field, $Values, $Op = 'in', $Escape = true)
{
if (is_null($Field) || !is_array($Values)) {
return;
}
$FieldExpr = $this->_parseExpr($Field);
// Build up the in clause.
$In = array();
foreach ($Values as $Value) {
if ($Escape) {
$ValueExpr = $this->Database->connection()->quote($Value);
} else {
$ValueExpr = (string) $Value;
}
if (strlen($ValueExpr) > 0) {
$In[] = $ValueExpr;
}
}
if (count($In) > 0) {
$InExpr = '(' . implode(', ', $In) . ')';
} else {
$InExpr = '(null)';
}
// Set the final expression.
$Expr = $FieldExpr . ' ' . $Op . ' ' . $InExpr;
$this->_where($Expr);
return $this;
}