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

@ -16,7 +16,7 @@ class MongoStatement extends DbStatement
protected $insertId = false;
public function order($sort = array())
public function order($sort = array())
{
if ($this->result instanceof MongoCursor) {
$this->result->sort($sort);
@ -96,8 +96,10 @@ class MongoStatement extends DbStatement
public function affectedRows()
{
if (is_array($this->result)) {
if (isset($this->result['ok']) && $this->result['ok'] == 1 && isset($this->result['n'])) {
return $this->result['n'];
if (isset($this->result['ok']) && $this->result['ok'] == 1) {
if (isset($this->result['n'])) {
return $this->result['n'];
}
} else {
return false;
}
@ -115,7 +117,7 @@ class MongoStatement extends DbStatement
}
/**
* @param MongoDbComand $request
* @param MongoDbCommand $request
* @return bool
*/
protected function driverExecute($request)
@ -134,8 +136,14 @@ class MongoStatement extends DbStatement
}
if ($result instanceof MongoCursor || is_array($result)) {
$this->result = $result;
if (is_array($result) && isset($result['value'])) {
$this->result = $result['value'];
}
if (is_array($result) && isset($result['values'])) {
$this->result = $result['values'];
}
}
if($request instanceof InsertMongoCommand) {
if ($request instanceof InsertMongoCommand) {
$this->insertId = $request->getInsertId();
}
return true;