added methods to MongoDriver for custom commands, findAndModify, count

This commit is contained in:
Anton Grebnev
2011-11-22 16:29:00 +04:00
parent 54b991314d
commit a87845980d
7 changed files with 156 additions and 7 deletions

View File

@ -18,6 +18,8 @@ class MongoCommandBuilder
const REMOVE = 'Remove';
const COMMAND = 'Command';
static public function factory($type, $collection = null)
{
$class = ucfirst($type) . 'MongoCommand';
@ -167,4 +169,26 @@ class RemoveMongoCommand extends MongoDbCommand
}
}
class CommandMongoCommand extends MongoDbCommand
{
protected $command;
protected function concreteExecute()
{
$db = $this->collection->db;
if($db instanceof MongoDB) {
return $db->command($this->command);
} else {
return false;
}
}
protected function checkParams()
{
if (isset($this->collection) && isset($this->command)) {
return true;
} else {
return false;
}
}
}