added Order, Limit, Skip methods to MongoStatement

This commit is contained in:
Anton Grebnev
2011-11-15 19:19:30 +04:00
parent 5b5ccb9971
commit 594ec034f9
6 changed files with 171 additions and 18 deletions

View File

@ -14,6 +14,36 @@
class MongoStatement extends DbStatement
{
public function order($sort = array())
{
if ($this->result instanceof MongoCursor) {
$this->result->sort($sort);
return $this;
} else {
throw new Exception('MongoStatement error. Impossible order results of opened cursor.');
}
}
public function skip($skip = 0)
{
if ($this->result instanceof MongoCursor) {
$this->result->skip($skip);
return $this;
} else {
throw new Exception('MongoStatement error. Impossible skip results of opened cursor.');
}
}
public function limit($limit = 0)
{
if ($this->result instanceof MongoCursor) {
$this->result->limit($limit);
return $this;
} else {
throw new Exception('MongoStatement error. Impossible limit results of opened cursor.');
}
}
public function fetch($style = Db::FETCH_OBJ)
{
if (!$this->result) {