Sokil\Mongo\Collection::expression PHP Method

expression() public method

Create new Expression instance to use in query builder or update operations
public expression ( ) : Expression
return Expression
    public function expression()
    {
        $className = $this->definition->getExpressionClass();
        return new $className();
    }

Usage Example

コード例 #1
0
ファイル: BatchTest.php プロジェクト: agolomazov/php-mongo
 public function testDelete()
 {
     // insert
     $this->collection->batchInsert(array(array('a' => 1), array('a' => 2), array('a' => 3), array('a' => 4), array('a' => 5), array('a' => 6)));
     // delete
     $batch = new BatchDelete($this->collection);
     $batch->delete(array('a' => 2))->delete($this->collection->expression()->where('a', 4))->delete(function (Expression $e) {
         $e->where('a', 6);
     })->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), array('a' => 3), array('a' => 5)));
 }
All Usage Examples Of Sokil\Mongo\Collection::expression