Doctrine\MongoDB\Query\Expr::addAnd PHP Method

addAnd() public method

Add one or more $and clauses to the current query.
See also: Builder::addAnd()
See also: http://docs.mongodb.org/manual/reference/operator/and/
public addAnd ( array | Expr $expression )
$expression array | Expr
    public function addAnd($expression)
    {
        if (!isset($this->query['$and'])) {
            $this->query['$and'] = [];
        }
        $this->query['$and'] = array_merge($this->query['$and'], array_map(function ($expression) {
            return $expression instanceof Expr ? $expression->getQuery() : $expression;
        }, func_get_args()));
        return $this;
    }

Usage Example

示例#1
0
 /**
  * Add an $and clause to the current query.
  *
  * You can create a new expression using the {@link Builder::expr()} method.
  *
  * @see Expr::addAnd()
  * @see http://docs.mongodb.org/manual/reference/operator/and/
  * @param array|Expr $expression
  * @return self
  */
 public function addAnd($expression)
 {
     $this->expr->addAnd($expression);
     return $this;
 }
All Usage Examples Of Doctrine\MongoDB\Query\Expr::addAnd