PHP Class MongoCursor

Inheritance: implements Iterator
Afficher le fichier Open project: alcaeus/mongo-php-adapter Class Usage Examples

Méthodes publiques

Свойство Type Description
$slaveOkay boolean
$timeout integer

Protected Properties

Свойство Type Description
$allowPartialResults
$awaitData
$flags
$hint
$limit
$maxTimeMS
$noCursorTimeout
$optionNames array
$options
$projection array
$query array
$skip
$snapshot
$sort
$tailable

Méthodes publiques

Méthode Description
__construct ( MongoClient $connection, string $ns, array $query = [], array $fields = [] ) Create a new cursor
__sleep ( ) : array
addOption ( string $key, mixed $value ) : MongoCursor Adds a top-level key/value pair to a query
awaitData ( boolean $wait = true ) : MongoCursor (PECL mongo >= 1.2.11)
Sets whether this cursor will wait for a while for a tailable cursor to return more data
count ( boolean $foundOnly = false ) : integer Counts the number of results for this query
explain ( ) : array Return an explanation of the query, often useful for optimization and debugging
fields ( array $f ) : MongoCursor Sets the fields for a query
getNext ( ) : array Advances the cursor to the next result, and returns that result
hasNext ( ) : boolean Checks if there are any more elements in this cursor
hint ( array | string $keyPattern ) : MongoCursor Gives the database a hint about the query
immortal ( boolean $liveForever = true ) : MongoCursor Sets whether this cursor will timeout
limit ( integer $num ) : MongoCursor Limits the number of results returned
maxTimeMS ( integer $ms )
partial ( boolean $okay = true ) : MongoCursor
reset ( ) : void Clears the cursor
setFlag ( integer $flag, boolean $set = true ) : MongoCursor
skip ( integer $num ) : MongoCursor Skips a number of results
slaveOkay ( boolean $okay = true ) : MongoCursor Sets whether this query can be done on a slave This method will override the static class variable slaveOkay.
snapshot ( ) : MongoCursor Use snapshot mode for the query
sort ( array $fields ) : MongoCursor Sorts the results by given fields
tailable ( boolean $tail = true ) : MongoCursor Sets whether this cursor will be left open after fetching the last results

Méthodes protégées

Méthode Description
convertCursorType ( ) : integer | null
convertModifiers ( ) : array
convertProjection ( ) : array
doQuery ( ) : void Execute the query
ensureCursor ( ) : MongoDB\Driver\Cursor
getCursorInfo ( ) : array
wrapTraversable ( Traversable $traversable ) : Generator

Method Details

__construct() public méthode

Create a new cursor
public __construct ( MongoClient $connection, string $ns, array $query = [], array $fields = [] )
$connection MongoClient Database connection.
$ns string Full name of database and collection.
$query array Database query.
$fields array Fields to return.

__sleep() public méthode

public __sleep ( ) : array
Résultat array

addOption() public méthode

Adds a top-level key/value pair to a query
public addOption ( string $key, mixed $value ) : MongoCursor
$key string Fieldname to add.
$value mixed Value to add.
Résultat MongoCursor Returns this cursor

awaitData() public méthode

(PECL mongo >= 1.2.11)
Sets whether this cursor will wait for a while for a tailable cursor to return more data
public awaitData ( boolean $wait = true ) : MongoCursor
$wait boolean [optional]

If the cursor should wait for more data to become available.

Résultat MongoCursor Returns this cursor.

convertCursorType() protected méthode

protected convertCursorType ( ) : integer | null
Résultat integer | null

convertModifiers() protected méthode

protected convertModifiers ( ) : array
Résultat array

convertProjection() protected méthode

protected convertProjection ( ) : array
Résultat array

count() public méthode

Counts the number of results for this query
public count ( boolean $foundOnly = false ) : integer
$foundOnly boolean Send cursor limit and skip information to the count function, if applicable.
Résultat integer The number of documents returned by this cursor's query.

doQuery() protected méthode

Execute the query
protected doQuery ( ) : void
Résultat void

ensureCursor() protected méthode

protected ensureCursor ( ) : MongoDB\Driver\Cursor
Résultat MongoDB\Driver\Cursor

explain() public méthode

Return an explanation of the query, often useful for optimization and debugging
public explain ( ) : array
Résultat array Returns an explanation of the query.

fields() public méthode

Sets the fields for a query
public fields ( array $f ) : MongoCursor
$f array Fields to return (or not return).
Résultat MongoCursor

getCursorInfo() protected méthode

protected getCursorInfo ( ) : array
Résultat array

getNext() public méthode

Advances the cursor to the next result, and returns that result
public getNext ( ) : array
Résultat array Returns the next object

hasNext() public méthode

Checks if there are any more elements in this cursor
public hasNext ( ) : boolean
Résultat boolean Returns true if there is another element

hint() public méthode

Gives the database a hint about the query
public hint ( array | string $keyPattern ) : MongoCursor
$keyPattern array | string Indexes to use for the query.
Résultat MongoCursor Returns this cursor

immortal() public méthode

Sets whether this cursor will timeout
public immortal ( boolean $liveForever = true ) : MongoCursor
$liveForever boolean If the cursor should be immortal.
Résultat MongoCursor Returns this cursor

limit() public méthode

Limits the number of results returned
public limit ( integer $num ) : MongoCursor
$num integer The number of results to return.
Résultat MongoCursor Returns this cursor

maxTimeMS() public méthode

public maxTimeMS ( integer $ms )
$ms integer

partial() public méthode

public partial ( boolean $okay = true ) : MongoCursor
$okay boolean [optional]

If receiving partial results is okay.

Résultat MongoCursor Returns this cursor.

reset() public méthode

Clears the cursor
public reset ( ) : void
Résultat void

setFlag() public méthode

public setFlag ( integer $flag, boolean $set = true ) : MongoCursor
$flag integer
$set boolean
Résultat MongoCursor

skip() public méthode

Skips a number of results
public skip ( integer $num ) : MongoCursor
$num integer The number of results to skip.
Résultat MongoCursor Returns this cursor

slaveOkay() public méthode

Sets whether this query can be done on a slave This method will override the static class variable slaveOkay.
public slaveOkay ( boolean $okay = true ) : MongoCursor
$okay boolean If it is okay to query the slave.
Résultat MongoCursor Returns this cursor

snapshot() public méthode

Use snapshot mode for the query
public snapshot ( ) : MongoCursor
Résultat MongoCursor Returns this cursor

sort() public méthode

Sorts the results by given fields
public sort ( array $fields ) : MongoCursor
$fields array An array of fields by which to sort. Each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort
Résultat MongoCursor Returns the same cursor that this method was called on

tailable() public méthode

Sets whether this cursor will be left open after fetching the last results
public tailable ( boolean $tail = true ) : MongoCursor
$tail boolean If the cursor should be tailable.
Résultat MongoCursor Returns this cursor

wrapTraversable() protected méthode

protected wrapTraversable ( Traversable $traversable ) : Generator
$traversable Traversable
Résultat Generator

Property Details

$allowPartialResults protected_oe property

protected $allowPartialResults

$awaitData protected_oe property

protected $awaitData

$flags protected_oe property

protected $flags

$hint protected_oe property

protected $hint

$limit protected_oe property

protected $limit

$maxTimeMS protected_oe property

protected $maxTimeMS

$noCursorTimeout protected_oe property

protected $noCursorTimeout

$optionNames protected_oe property

protected array $optionNames
Résultat array

$options protected_oe property

protected $options

$projection protected_oe property

protected array $projection
Résultat array

$query protected_oe property

protected array $query
Résultat array

$skip protected_oe property

protected $skip

$slaveOkay public_oe static_oe property

public static bool $slaveOkay
Résultat boolean

$snapshot protected_oe property

protected $snapshot

$sort protected_oe property

protected $sort

$tailable protected_oe property

protected $tailable

$timeout public_oe static_oe property

public static int $timeout
Résultat integer