MongoCursor
class MongoCursor implements Iterator (View source)
Result object for database query.
Properties
static bool | $slaveOkay | ||
static int | $timeout |
Methods
Create a new cursor
(PECL mongo >= 1.2.11)
Sets whether this cursor will wait for a while for a tailable cursor to return more data
Checks if there are any more elements in this cursor
Return the next object to which this cursor points, and advance the cursor
(PECL mongo >= 1.3.3)
Limits the number of results returned
(PECL mongo >= 1.2.0)
(PECL mongo >= 1.2.1)
(PECL mongo >= 1.3.3)
Skips a number of results
Sets whether this query can be done on a slave This method will override the static class variable slaveOkay.
Sets whether this cursor will be left open after fetching the last results
Sets whether this cursor will timeout
Sets a client-side timeout for this query
Checks if there are documents that have not been sent yet from the database for this cursor
Use snapshot mode for the query
Sorts the results by given fields
Gives the database a hint about the query
Adds a top-level key/value pair to a query
Execute the query
Returns the current element
Returns the current result's _id
Advances the cursor to the next result
Returns the cursor to the beginning of the result set
Checks if the cursor is reading a valid result.
Clears the cursor
Return an explanation of the query, often useful for optimization and debugging
Counts the number of results for this query
Sets the fields for a query
Gets the query, fields, limit, and skip for this cursor
PECL mongo >= 1.0.11 Limits the number of elements returned in one batch.
(PECL mongo >= 1.5.0) Sets a server-side timeout for this query
Details
__construct(MongoClient $connection, string $ns, array $query = [], array $fields = [])
Create a new cursor
MongoCursor
awaitData(bool $wait = true)
(PECL mongo >= 1.2.11)
Sets whether this cursor will wait for a while for a tailable cursor to return more data
bool
hasNext()
Checks if there are any more elements in this cursor
array
getNext()
Return the next object to which this cursor points, and advance the cursor
array
getReadPreference()
(PECL mongo >= 1.3.3)
MongoCursor
limit(int $num)
Limits the number of results returned
MongoCursor
partial(bool $okay = true)
(PECL mongo >= 1.2.0)
MongoCursor
setFlag(int $flag, bool $set = true)
(PECL mongo >= 1.2.1)
MongoCursor
setReadPreference(string $read_preference, array $tags)
(PECL mongo >= 1.3.3)
MongoCursor
skip(int $num)
Skips a number of results
MongoCursor
slaveOkay(bool $okay = true)
Sets whether this query can be done on a slave This method will override the static class variable slaveOkay.
MongoCursor
tailable(bool $tail = true)
Sets whether this cursor will be left open after fetching the last results
MongoCursor
immortal(bool $liveForever = true)
Sets whether this cursor will timeout
MongoCursor
timeout(int $ms)
Sets a client-side timeout for this query
bool
dead()
Checks if there are documents that have not been sent yet from the database for this cursor
MongoCursor
snapshot()
Use snapshot mode for the query
MongoCursor
sort(array $fields)
Sorts the results by given fields
MongoCursor
hint(mixed $key_pattern)
Gives the database a hint about the query
MongoCursor
addOption(string $key, mixed $value)
Adds a top-level key/value pair to a query
protected void
doQuery()
Execute the query
mixed
current()
Returns the current element
mixed
key()
Returns the current result's _id
void
next()
Advances the cursor to the next result
void
rewind()
Returns the cursor to the beginning of the result set
bool
valid()
Checks if the cursor is reading a valid result.
void
reset()
Clears the cursor
array
explain()
Return an explanation of the query, often useful for optimization and debugging
int
count(bool $all = false)
Counts the number of results for this query
MongoCursor
fields(array $f)
Sets the fields for a query
array
info()
Gets the query, fields, limit, and skip for this cursor
MongoCursor
batchSize(int $batchSize)
PECL mongo >= 1.0.11 Limits the number of elements returned in one batch.
A cursor typically fetches a batch of result objects and store them locally. This method sets the batchSize value to configure the amount of documents retrieved from the server in one data packet. However, it will never return more documents than fit in the max batch size limit (usually 4MB).
MongoCursor
maxTimeMS(int $ms)
(PECL mongo >= 1.5.0) Sets a server-side timeout for this query