Sokil\Mongo\Collection::operator PHP 메소드

operator() 공개 메소드

Create Operator instance to use in update operations
public operator ( ) : Operator
리턴 Operator
    public function operator()
    {
        return new Operator();
    }

Usage Example

예제 #1
0
 public function testUpdate()
 {
     // insert
     $this->collection->batchInsert(array(array('a' => 1, 'b' => 1), array('a' => 2, 'b' => 2), array('a' => 3, 'b' => 3)));
     // update
     $batch = new BatchUpdate($this->collection);
     $batch->update(array('a' => 1), array('$set' => array('b' => 'updated1')))->update($this->collection->expression()->where('a', 2), $this->collection->operator()->set('b', 'updated2'))->update(function (Expression $e) {
         $e->where('a', 3);
     }, function (Operator $o) {
         $o->set('b', 'updated3');
     })->execute();
     // test
     $result = $this->collection->findAsArray()->sort(array('a' => 1))->map(function ($data) {
         unset($data['_id']);
         return $data;
     });
     $this->assertEquals(array_values($result), array(array('a' => 1, 'b' => 'updated1'), array('a' => 2, 'b' => 'updated2'), array('a' => 3, 'b' => 'updated3')));
 }
All Usage Examples Of Sokil\Mongo\Collection::operator