Skip to content

Commit

Permalink
Reproduce some commonly used functions on MongoCursor in EMongoCursor
Browse files Browse the repository at this point in the history
  • Loading branch information
canni committed Dec 27, 2010
1 parent 9b3f4de commit 043827b
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions EMongoCursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,42 @@ public function valid()

/**
* Returns the number of documents found
* {@see http://www.php.net/manual/en/mongocursor.count.php}
* @param boolean $foundOnly default FALSE
* @return integer count of documents found
*/
public function count()
public function count($foundOnly = false)
{
return $this->_cursor->count(true);
return $this->_cursor->count($foundOnly);
}

/**
* Apply a limit to this cursor
* {@see http://www.php.net/manual/en/mongocursor.limit.php}
* @param integer $limit new limit
*/
public function limit($limit)
{
$this->_cursor->limit($limit);
}

/**
* Skip a $offset records
* {@see http://www.php.net/manual/en/mongocursor.skip.php}
* @param integer $skip new skip
*/
public function offset($offset)
{
$this->_cursor->offset($offset);
}

/**
* Apply sorting directives
* {@see http://www.php.net/manual/en/mongocursor.sort.php}
* @param array $sort sorting directives
*/
public function sort(array $fields)
{
$this->_cursor->sort($fields);
}
}

0 comments on commit 043827b

Please sign in to comment.