diff --git a/suda/src/database/statement/WherePrepareTrait.php b/suda/src/database/statement/WherePrepareTrait.php index 6cf2c0e8..930d1dad 100644 --- a/suda/src/database/statement/WherePrepareTrait.php +++ b/suda/src/database/statement/WherePrepareTrait.php @@ -176,15 +176,24 @@ protected function normalizeWhereArray(array $where) } $newWhere = []; foreach ($where as $name => $value) { - if (is_array($value) && $this->countObject($value) === 2) { + if (is_array($value)) { $newWhere[] = [$name, $value[0], $value[1]]; } else { - $newWhere[] = [$name, '=', $value]; + $op = $this->isArray($value)?'in':'='; + $newWhere[] = [$name, $op, $value]; } } return $newWhere; } + /** + * @param $value + * @return bool + */ + protected function isArray($value) { + return is_array($value) || $value instanceof IteratorAggregate; + } + /** * @param array $where * @return bool @@ -203,7 +212,7 @@ protected function isNumberArray(array $where) */ public function getQueryForString(string $where, string $name, $value) { - if (is_array($value) || $value instanceof IteratorAggregate) { + if ($this->isArray($value)) { [$inSQL, $binders] = $this->prepareInParameter($value, $name); $where = $this->replaceQuote($name, $inSQL, $where); return new Query($where, $binders);