added count() method to MongoModel

This commit is contained in:
Anton Grebnev
2012-04-02 15:21:37 +04:00
parent c7dcd33512
commit a1bfcdd78b
3 changed files with 63 additions and 3 deletions

View File

@ -28,7 +28,14 @@ class MongoDriver extends NoSqlDbDriver
public function count($collection, $query = array(), $limit = 0, $skip = 0)
{
return $this->getCollection($collection)->count($query, $limit, $skip);
$command = MongoCommandBuilder::factory(MongoCommandBuilder::COUNT, $this->getCollection($collection));
$params = array(
'condition' => $query,
'limit' => $limit,
'skip' => $skip
);
return $this->query($command, $params)->affectedRows();
}
public function find($collection, $condition = array(), $fields = array())