Pagekit\Database\Query\QueryBuilder::addWhere PHP Метод

addWhere() защищенный Метод

Creates and adds a "where" to the query.
protected addWhere ( mixed $condition, array $params, string $type = null ) : self
$condition mixed
$params array
$type string
Результат self
    protected function addWhere($condition, array $params, $type = null)
    {
        $args = [];
        if (null === $type) {
            $type = CompositeExpression::TYPE_AND;
        }
        if (is_string($condition)) {
            $condition = [$condition];
        }
        if (is_array($condition)) {
            foreach ($condition as $key => $value) {
                if (!is_numeric($key)) {
                    $name = $this->parameter($key);
                    $params[$name] = $value;
                    $value = "{$key} = :{$name}";
                }
                $args[] = $value;
            }
        } elseif ($condition instanceof Closure) {
            $query = $this->newQuery();
            $query->from($this->getPart('from'));
            call_user_func($condition, $query);
            $args[] = $query->getPart('where');
            $params = $query->params();
        }
        $this->params($params);
        $where = $this->getPart('where');
        if ($where instanceof CompositeExpression && $where->getType() === $type) {
            $where->addMultiple($args);
        } else {
            array_unshift($args, $where);
            $where = new CompositeExpression($type, $args);
        }
        return $this->addPart('where', $where);
    }