added Order, Limit, Skip methods to MongoStatement
This commit is contained in:
@ -88,18 +88,6 @@ abstract class DbStatement
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function fetchPairs()
|
||||
{
|
||||
$data = array();
|
||||
while ($row = $this->fetch(Db::FETCH_NUM)) {
|
||||
$data[$row[0]] = $row[1];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Abstract methods */
|
||||
|
||||
abstract public function bindParam($param, &$value);
|
||||
|
@ -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) {
|
||||
|
@ -117,6 +117,18 @@ class MySQLiStatement extends DbStatement
|
||||
{
|
||||
return $this->result->fetch_object($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function fetchPairs()
|
||||
{
|
||||
$data = array();
|
||||
while ($row = $this->fetch(Db::FETCH_NUM)) {
|
||||
$data[$row[0]] = $row[1];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
|
Reference in New Issue
Block a user