Skip to content

Commit

Permalink
Completed MongoCursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammaye committed Aug 28, 2013
1 parent 3fe2687 commit 6c81d3b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions EMongoCursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class EMongoCursor implements Iterator, Countable{
* @var EMongoDocument
*/
public $model;

/**
* @var array|MongoCursor|EMongoDocument[]
*/
Expand All @@ -46,7 +45,7 @@ class EMongoCursor implements Iterator, Countable{
* The cursor constructor
* @param string|EMongoDocument $modelClass - The class name for the active record
* @param array|MongoCursor|EMongoCriteria $criteria - Either a condition array (without sort,limit and skip) or a MongoCursor Object
* @param string[] $fields
* @param array $fields
*/
public function __construct($modelClass, $criteria = array(), $fields = array()) {
// If $fields has something in it
Expand Down Expand Up @@ -76,8 +75,6 @@ public function __construct($modelClass, $criteria = array(), $fields = array())
$this->criteria = $criteria;
$this->cursor = $this->model->getCollection()->find($criteria, $fields);
}
// TODO I think this is should to investigate and remove
return $this; // Maintain chainability
}

/**
Expand Down Expand Up @@ -126,6 +123,10 @@ public function current() {
}

/**
* Counts the records returned by the criteria. By default this will not take skip and limit into account
* you can add inject true as the first and only parameter to enable MongoDB to take those offsets into
* consideration.
*
* @param bool $takeSkip
* @return int
*/
Expand Down Expand Up @@ -154,6 +155,7 @@ public function sort(array $fields){
}

/**
* Set skip
* @param int $num
* @return EMongoCursor
*/
Expand All @@ -173,6 +175,7 @@ public function limit($num = 0){
}

/**
* Reset the MongoCursor to the beginning
* @return EMongoCursor
*/
public function rewind() {
Expand All @@ -181,6 +184,7 @@ public function rewind() {
}

/**
* Get the current key (_id)
* @return mixed|string
*/
public function key() {
Expand All @@ -195,6 +199,7 @@ public function next() {
}

/**
* Check if this position is a valid one in the cursor
* @return bool
*/
public function valid() {
Expand Down

0 comments on commit 6c81d3b

Please sign in to comment.