add() public method

The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date.
See also: http://docs.mongodb.org/manual/reference/operator/aggregation/add/
public add ( mixed | self $expression1, mixed | self $expression2 )
$expression1 mixed | self
$expression2 mixed | self
Esempio n. 1
0
 public function testMap()
 {
     $in = new Expr();
     $in->add('$$grade', 2);
     $expr = new Expr();
     $this->assertSame($expr, $expr->field('adjustedGrades')->map('$quizzes', 'grade', $in));
     $this->assertSame(array('adjustedGrades' => array('$map' => array('input' => '$quizzes', 'as' => 'grade', 'in' => array('$add' => array('$$grade', 2))))), $expr->getExpression());
 }
Esempio n. 2
0
 /**
  * Adds numbers together or adds numbers and a date. If one of the arguments
  * is a date, $add treats the other arguments as milliseconds to add to the
  * date.
  *
  * The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date.
  *
  * @see http://docs.mongodb.org/manual/reference/operator/aggregation/add/
  * @see Expr::add
  * @param mixed|Expr $expression1
  * @param mixed|Expr $expression2
  * @param mixed|Expr $expression3,... Additional expressions
  * @return $this
  */
 public function add($expression1, $expression2)
 {
     $this->expr->add(...func_get_args());
     return $this;
 }