Skip to content

Commit

Permalink
调整:IN
Browse files Browse the repository at this point in the history
  • Loading branch information
dxkite committed Feb 16, 2020
1 parent b2f55b8 commit e796430
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions suda/src/database/statement/WherePrepareTrait.php
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit e796430

Please sign in to comment.