each() 공개 메소드

Add $each criteria to the expression for a $push operation.
또한 보기: Expr::push()
또한 보기: http://docs.mongodb.org/manual/reference/operator/each/
public each ( array $values )
$values array
예제 #1
0
 public function testPushWithPosition()
 {
     $expr = new Expr();
     $innerExpr = new Expr();
     $innerExpr->each(array(20, 30))->position(0);
     $expectedNewObj = array('$push' => array('a' => array('$each' => array(20, 30), '$position' => 0)));
     $this->assertSame($expr, $expr->field('a')->push($innerExpr));
     $this->assertEquals($expectedNewObj, $expr->getNewObj());
 }
예제 #2
0
파일: ExprTest.php 프로젝트: im286er/ent
 public function testPushWithExpression()
 {
     $expr = new Expr();
     $innerExpr = new Expr();
     $innerExpr->each(array(array('x' => 1), array('x' => 2)))->slice(-2)->sort('x', 1);
     $expectedNewObj = array('$push' => array('a' => array('$each' => array(array('x' => 1), array('x' => 2)), '$slice' => -2, '$sort' => array('x' => 1))));
     $this->assertSame($expr, $expr->field('a')->push($innerExpr));
     $this->assertEquals($expectedNewObj, $expr->getNewObj());
 }
예제 #3
0
 public function testPushWithPosition()
 {
     $expr = new Expr();
     $innerExpr = new Expr();
     $innerExpr->each([20, 30])->position(0);
     $expectedNewObj = ['$push' => ['a' => ['$each' => [20, 30], '$position' => 0]]];
     $this->assertSame($expr, $expr->field('a')->push($innerExpr));
     $this->assertEquals($expectedNewObj, $expr->getNewObj());
 }