|
|
@ -26,6 +26,11 @@ class MongoDriver extends NoSqlDbDriver |
|
|
|
return $this->connection->selectCollection($this->db, $name); |
|
|
|
} |
|
|
|
|
|
|
|
public function count($collection, $query = array(), $limit = 0, $skip = 0) |
|
|
|
{ |
|
|
|
return $this->getCollection($collection)->count($query, $limit, $skip); |
|
|
|
} |
|
|
|
|
|
|
|
public function find($collection, $condition = array(), $fields = array()) |
|
|
|
{ |
|
|
|
$command = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $this->getCollection($collection)); |
|
|
@ -48,6 +53,30 @@ class MongoDriver extends NoSqlDbDriver |
|
|
|
return $this->query($command, $params); |
|
|
|
} |
|
|
|
|
|
|
|
public function findAndModify($collection, $query, $update, $sort = array(), $field = array(), $upsert = false, $new = false, $remove = false) |
|
|
|
{ |
|
|
|
$command = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, $this->getCollection($collection)); |
|
|
|
$cmd = array( |
|
|
|
'findAndModify' => $collection, |
|
|
|
'query' => $query, |
|
|
|
'update' => $update, |
|
|
|
'sort' => $sort, |
|
|
|
'fields' => $field, |
|
|
|
'new' => $new, |
|
|
|
'upsert' => $upsert, |
|
|
|
'remove' => $remove |
|
|
|
); |
|
|
|
$params = array('command' => $cmd); |
|
|
|
return $this->query($command, $params); |
|
|
|
} |
|
|
|
|
|
|
|
public function command($collection, $cmd) |
|
|
|
{ |
|
|
|
$command = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, $this->getCollection($collection)); |
|
|
|
$params = array('command' => $cmd); |
|
|
|
return $this->query($command, $params); |
|
|
|
} |
|
|
|
|
|
|
|
public function insert($collection, $data, $safe = true) |
|
|
|
{ |
|
|
|
$command = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->getCollection($collection)); |
|
|
@ -85,6 +114,8 @@ class MongoDriver extends NoSqlDbDriver |
|
|
|
return $this->query($command, $params)->affectedRows(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param mixed $request |
|
|
|
* @return DbStatement |
|
|
|