Combine two nodes (string field or nested Criteria object) using the AND operator.

@param string|Criteria $field
@return $this
@throws \InvalidArgumentException if field is not a string or a Criteria object
166621
public function andWhere($field)
    {
        if ($field instanceof Criteria) {
            return $this->root->inject(Node::OPERATOR_AND, $field->root)->getMostRecentCriteria();
        }

        return $this->root->append(Node::OPERATOR_AND, new Criteria($field, $this->root))->getMostRecentCriteria();
    }
401319
public function where($field, $op = null, $condition = null)
    {
        $param = func_get_args();
        array_shift($param);
        $this->parseWhereExp('and', $field, $op, $condition, $param);
        return $this;
    }
396118
public function root($field = 'root', callable $callback = null)
    {
        $this->addSelfReferencingRelation($field, $callback);

        $this->root = $field;

        return $this;
    }
912750
private function getFields($field)
    {
        if ($field instanceof Group || $field instanceof Fieldset) {
            $elements = $field->getFields();
        } elseif ($field instanceof AbstractField) {
            $elements = [$field];
        } else {
            throw new \InvalidArgumentException(sprintf(
                "Invalid type '%s'",
                is_object($field) ? get_class($field) : gettype($field)
            ));
        }

        return $elements;
    }
670119
public function alias($field, $alias)
    {
        $this->fields[$alias] = $this->prepareField($field);

        return $this;
    }
292992
public function addCriteria(Criteria $criteria)
    {
        $allAliases = $this->getAllAliases();
        if (! isset($allAliases[0])) {
            throw new Query\QueryException('No aliases are set before invoking addCriteria().');
        }

        $visitor         = new QueryExpressionVisitor($this->getAllAliases());
        $whereExpression = $criteria->getWhereExpression();

        if ($whereExpression) {
            $this->andWhere($visitor->dispatch($whereExpression));
            foreach ($visitor->getParameters() as $parameter) {
                $this->parameters->add($parameter);
            }
        }

        if ($criteria->getOrderings()) {
            foreach ($criteria->getOrderings() as $sort => $order) {
                $hasValidAlias = false;
                foreach ($allAliases as $alias) {
                    if (strpos($sort . '.', $alias . '.') === 0) {
                        $hasValidAlias = true;
                        break;
                    }
                }

                if (! $hasValidAlias) {
                    $sort = $allAliases[0] . '.' . $sort;
                }

                $this->addOrderBy($sort, $order);
            }
        }

        $firstResult = $criteria->getFirstResult();
        $maxResults  = $criteria->getMaxResults();

        // Overwrite limits only if they was set in criteria
        if ($firstResult !== null) {
            $this->setFirstResult($firstResult);
        }
        if ($maxResults !== null) {
            $this->setMaxResults($maxResults);
        }

        return $this;
    }
1268991
public function orderBy($field, $order)
    {
        if (!in_array($field, $this->getAvailableFields())) {
            throw new \InvalidArgumentException(sprintf('Field "%s" not supported, prefer: %s', $field, implode(', ', $this->getAvailableFields())));
        }

        if (!in_array($order, array('ASC', 'DESC'))) {
            throw new \InvalidArgumentException(sprintf('Order "%s" not supported, prefer: ASC or DESC', $order));
        }

        $this->sort = array($field, $order);

        return $this;
    }
1172138
private function bracketCriteria(array &$criteria, string $bracket = self::BRACKET_OPEN, string $connector = self::LOGICAL_AND): self
    {
        $criteria[] = [
            'bracket'   => $bracket,
            'connector' => $connector,
        ];

        return $this;
    }
685617
public function addCriteria($criteria = null, $operator = 'AND')
    {
        if ($criteria instanceof Criteria) {
            $query = $criteria->getQuery();
            // 添加 WHERE 条件
            isset($query['where']) && $this->addWhere($query['where'], $criteria->getParams(), $operator);
        }
        return $this;
    }
1083928
public function matching(Criteria $criteria)
    {
        $clause = [];
        /** @var Comparison $whereClause */
        $whereClause = $criteria->getWhereExpression();
        if (null !== $whereClause) {
            if (Comparison::EQ !== $whereClause->getOperator()) {
                throw new \InvalidArgumentException(sprintf('Support for Selectable is limited to the EQUALS "=" operator, 
                 % given', $whereClause->getOperator()));
            }

            $clause = [$whereClause->getField() => $whereClause->getValue()->getValue()];
        }

        return $this->findBy($clause, $criteria->getOrderings(), $criteria->getMaxResults(), $criteria->getFirstResult());
    }
161921
public function criteria($criteria = null)
    {
        if (is_null($criteria)) {
            return $this->mediator->criteria();
        }

        if (!is_null($criteria) && !is_a($criteria, CriteriaInterface::class)) {
            throw new InvalidCriteria();
        }

        $this->mediator->criteria()->addCriteria($criteria);

        return $this;
    }
88565
public function allowField($field)
    {
        if (is_string($field)) {
            $field = explode(',', $field);
        }

        $this->field = $field;

        return $this;
    }
1072586
public function increment($field, $step = 1)
    {
        if (!in_array($field, $this->getFields(), true)) {
            throw new InvalidArgumentException([':field field is invalid.', 'field' => $field]);
        }

        $this->$field = new Increment($step);

        return $this;
    }
1351239
public function addAnd(AbstractCriterion $criterion)
    {
        $this->clauses[] = $criterion;
        $this->conjunctions[] = self::UND;

        return $this;
    }
90395
public function add($field, Constraint $constraint)
    {
        if (!isset($this->constraints[$field])) {
            $this->constraints['fields'][$field] = [];
        }

        $this->constraints['fields'][$field][] = $constraint;

        return $this;
    }
234690
public function addField($field, $default = null)
    {
        if ($default !== null && (is_array($default) || is_object($default))) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Default value should be scalar, %s given.',
                    gettype($default)
                )
            );
        }

        $defaultProfile = [
            'Field' => '',
            'Type' => '',
            'Collation' => 'utf8_unicode_ci',
            'Null' => 'NO',
            'Key' => '',
            'Default' => '',
            'Extra' => '',
            'Privileges' => 'select,insert,update,references',
            'Comment' => '',
        ];

        if (is_string($field)) {
            $field = array_merge(
                $defaultProfile,
                [
                    'Field' => $field,
                    'Type' => gettype($default),
                    'Default' => $default,
                ]
            );
        }

        if (is_array($field) || is_object($field)) {
            $field = array_merge($defaultProfile, (array) $field);
        }

        $field = (object) $field;

        $this->fields[$field->Field] = $field;

        return $this;
    }
389533
public function indexBy($field)
    {
        $elements = $this->toArray();
        $this->clear();

        foreach ($elements as $element) {
            $this->set(
                $this->getFieldValue($element, $field),
                $element
            );
        }

        return $this;
    }