multiply() public method

The arguments can be any valid expression as long as they resolve to numbers.
See also: http://docs.mongodb.org/manual/reference/operator/aggregation/multiply/
public multiply ( mixed | self $expression1, mixed | self $expression2 )
$expression1 mixed | self
$expression2 mixed | self
Exemplo n.º 1
0
 public function testLet()
 {
     $vars = new Expr();
     $vars->field('total')->add('$price', '$tax')->field('discounted')->cond('$applyDiscount', 0.9, 1);
     $in = new Expr();
     $in->multiply('$$total', '$$discounted');
     $expr = new Expr();
     $this->assertSame($expr, $expr->field('finalTotal')->let($vars, $in));
     $this->assertSame(array('finalTotal' => array('$let' => array('vars' => array('total' => array('$add' => array('$price', '$tax')), 'discounted' => array('$cond' => array('if' => '$applyDiscount', 'then' => 0.9, 'else' => 1))), 'in' => array('$multiply' => array('$$total', '$$discounted'))))), $expr->getExpression());
 }
Exemplo n.º 2
0
 /**
  * Multiplies numbers together and returns the result.
  *
  * The arguments can be any valid expression as long as they resolve to numbers.
  *
  * @see http://docs.mongodb.org/manual/reference/operator/aggregation/multiply/
  * @see Expr::multiply
  * @param mixed|Expr $expression1
  * @param mixed|Expr $expression2
  * @param mixed|Expr $expression3,... Additional expressions
  * @return $this
  */
 public function multiply($expression1, $expression2)
 {
     $this->expr->multiply(...func_get_args());
     return $this;
 }