Mongo
PHP Manual

The MongoCursor class

Introduction

Result object for database query.

The database is not actually queried until next() or hasNext() is called. Before the database is queried, commands can be strung together, as in:

<?php
$cursor = $collection->find()->limit(10);

// database has not yet been queried, so more search options can be added
$cursor = $cursor->sort(array("a" => 1));

var_dump($cursor->getNext());
// now database has been queried and more options cannot be added

// so this will throw an exception:
$cursor->skip(4);
?>

Class synopsis

MongoCursor
implements Iterator {
/* Static Fields */
static boolean $slaveOkay = FALSE ;
/* Methods */
__construct ( resource $connection , string $ns [, array $query = array() [, array $fields = array() ]] )
public int count ( void )
public array current ( void )
protected void doQuery ( void )
public array explain ( void )
public array getNext ( void )
public boolean hasNext ( void )
public MongoCursor hint ( array $key_pattern )
public string key ( void )
public MongoCursor limit ( int $num )
public void next ( void )
public void reset ( void )
public void rewind ( void )
public MongoCursor skip ( int $num )
public MongoCursor slaveOkay ([ boolean $okay = true ] )
public MongoCursor sort ( array $fields )
public MongoCursor tailable ([ boolean $tail = true ] )
public boolean valid ( void )
}

Table of Contents


Mongo
PHP Manual