downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoCursor::__construct> <MongoCollection::validate
Last updated: Fri, 20 Nov 2009

view this page in

The MongoCursor class

Wstęp

Result object for database query.

A MongoCursor has two "life stages": pre- and post- query. A cursor can be created manually by calling the constructor, but it is most often created by calling MongoCollection::find(). When a cursor is created, it has not yet contacted the database, so it is in its pre-query state. In this state, the client can further specify what they want the query to do, including adding limits, skips, sorts, and more advanced options.

When the client attempts to get a result (by calling MongoCursor::next(), directly or indirectly), the cursor moves into the post-query stage. At this point, the query has been executed by the database and cannot be modified anymore. At this point, the only functions available are the Iterator functions, MongoCursor::hasNext(), and MongoCursor::getNext().

<?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);
?>

Krótki opis klasy

MongoCursor
implements Iterator {
/* Static Fields */
static boolean $slaveOkay = FALSE ;
/* Methods */
__construct ( resource $connection , string $ns [, array $query = array() [, array $fields = array() ]] )
public int count ([ boolean $all = FALSE ] )
public array current ( void )
public boolean dead ( void )
protected void doQuery ( void )
public array explain ( void )
public array getNext ( void )
public boolean hasNext ( void )
public MongoCursor hint ( array $key_pattern )
public MongoCursor immortal ([ boolean $liveForever = true ] )
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 snapshot ( void )
public MongoCursor sort ( array $fields )
public MongoCursor tailable ([ boolean $tail = true ] )
public boolean valid ( void )
}

Spis treści



add a note add a note User Contributed Notes
MongoCursor
There are no user contributed notes for this page.

MongoCursor::__construct> <MongoCollection::validate
Last updated: Fri, 20 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites