ManaPHP\Mvc\Model\QueryBuilder::inWhere PHP Метод

inWhere() публичный Метод

$builder->inWhere('id', [1, 2, 3]);
public inWhere ( string $expr, array | ManaPHP\Mvc\Model\QueryBuilderInterface $values ) : static
$expr string
$values array | ManaPHP\Mvc\Model\QueryBuilderInterface
Результат static
    public function inWhere($expr, $values)
    {
        if ($values instanceof $this) {
            $this->andWhere($expr . ' IN (' . $values->getSql() . ')');
            $this->_bind = array_merge($this->_bind, $values->getBind());
        } else {
            if (count($values) === 0) {
                $this->andWhere('1=2');
                return $this;
            }
            $bind = [];
            $bindKeys = [];
            /** @noinspection ForeachSourceInspection */
            foreach ($values as $k => $value) {
                $key = '_in_' . self::$_hiddenParamNumber . '_' . $k;
                $bindKeys[] = ":{$key}";
                $bind[$key] = $value;
            }
            self::$_hiddenParamNumber++;
            $this->andWhere($expr . ' IN (' . implode(', ', $bindKeys) . ')', $bind);
        }
        return $this;
    }