class EagerCursor extends Cursor (View source)

deprecated Deprecated in favor of using Cursor; will be removed in 2.0

EagerCursor wraps a Cursor instance and fetches all of its results upon initialization.

Methods

__construct(CursorInterface $baseCursor, UnitOfWork $unitOfWork, ClassMetadata $class)

Constructor.

from Cursor
CursorInterface
getBaseCursor()

Return the wrapped Doctrine\MongoDB\Cursor instance.

from Cursor
Connection
getConnection()

Return the database connection for this cursor.

from Cursor
Collection
getCollection()

Return the collection for this cursor.

from Cursor
array
getFields()

Return the selected fields (projection).

from Cursor
array
getHints()

Get hints for UnitOfWork behavior.

from Cursor
setHints(array $hints)

Set hints for UnitOfWork behavior.

from Cursor
array
getQuery()

Return the query criteria.

from Cursor
$this
addOption(string $key, mixed $value)

Wrapper method for MongoCursor::addOption().

from Cursor
$this
batchSize(integer $num)

Wrapper method for MongoCursor::batchSize().

from Cursor
integer
count(boolean $foundOnly = false)

Wrapper method for MongoCursor::count().

from Cursor
array|object|null
current()

Wrapper method for MongoCursor::current().

from Cursor
boolean
dead()

Wrapper method for MongoCursor::dead().

from Cursor
array
explain()

Wrapper method for MongoCursor::explain().

from Cursor
$this
fields(array $f)

Wrapper method for MongoCursor::fields().

from Cursor
array|object|null
getNext()

Wrapper method for MongoCursor::getNext().

from Cursor
array
getReadPreference()

Wrapper method for MongoCursor::getReadPreference().

from Cursor
$this
setReadPreference(string $readPreference, array $tags = null)

Wrapper method for MongoCursor::setReadPreference().

from Cursor
array|object|null
getSingleResult()

Reset the cursor and return its first result.

from Cursor
getUseIdentifierKeys()

{@inheritDoc}

from Cursor
setUseIdentifierKeys($useIdentifierKeys)

{@inheritDoc}

from Cursor
hasNext()

{@inheritDoc}

from Cursor
$this
hint(array|string $keyPattern)

Wrapper method for MongoCursor::hint().

from Cursor
$this
hydrate(boolean $hydrate = true)

Set whether to hydrate results as document class instances.

from Cursor
$this
immortal(boolean $liveForever = true)

Wrapper method for MongoCursor::immortal().

from Cursor
array
info()

Wrapper method for MongoCursor::info().

from Cursor
string
key()

Wrapper method for MongoCursor::key().

from Cursor
$this
limit(integer $num)

Wrapper method for MongoCursor::limit().

from Cursor
next()

Wrapper method for MongoCursor::next().

from Cursor
recreate()

Recreates the internal MongoCursor.

from Cursor
$this
refresh(boolean $refresh = true)

Set whether to refresh hydrated documents that are already in the identity map.

from Cursor
reset()

Wrapper method for MongoCursor::reset().

from Cursor
rewind()

Wrapper method for MongoCursor::rewind().

from Cursor
$this
skip(integer $num)

Wrapper method for MongoCursor::skip().

from Cursor
$this
slaveOkay(boolean $ok = true)

Wrapper method for MongoCursor::slaveOkay().

from Cursor
$this
snapshot()

Wrapper method for MongoCursor::snapshot().

from Cursor
$this
sort(array $fields)

Wrapper method for MongoCursor::sort().

from Cursor
$this
tailable(boolean $tail = true)

Wrapper method for MongoCursor::tailable().

from Cursor
$this
timeout(integer $ms)

Wrapper method for MongoCursor::timeout().

from Cursor
array
toArray(boolean $useIdentifierKeys = null)

Return the cursor's results as an array.

from Cursor
boolean
valid()

Wrapper method for MongoCursor::valid().

from Cursor
$this
enableReferencePriming(array $primers, ReferencePrimer $referencePrimer)

No description

from Cursor
primeReferences()

Prime references

from Cursor
primeReferencesForSingleResult(object $document)

Primes all references for a single document only. This avoids iterating over the entire cursor when getSingleResult() is called.

from Cursor

Details

__construct(CursorInterface $baseCursor, UnitOfWork $unitOfWork, ClassMetadata $class)

Constructor.

Parameters

CursorInterface $baseCursor Cursor instance being wrapped
UnitOfWork $unitOfWork UnitOfWork for result hydration and query preparation
ClassMetadata $class ClassMetadata for the document class being queried

CursorInterface getBaseCursor()

Return the wrapped Doctrine\MongoDB\Cursor instance.

Return Value

CursorInterface

Connection getConnection()

Return the database connection for this cursor.

Return Value

Connection

See also

\Doctrine\MongoDB\Cursor::getConnection()

Collection getCollection()

Return the collection for this cursor.

Return Value

Collection

See also

CursorInterface::getCollection()

array getFields()

Return the selected fields (projection).

Return Value

array

See also

CursorInterface::getFields()

array getHints()

Get hints for UnitOfWork behavior.

Return Value

array

setHints(array $hints)

Set hints for UnitOfWork behavior.

Parameters

array $hints

array getQuery()

Return the query criteria.

Return Value

array

See also

CursorInterface::getQuery()

$this addOption(string $key, mixed $value)

Wrapper method for MongoCursor::addOption().

Parameters

string $key
mixed $value

Return Value

$this

See also

CursorInterface::addOption()
http://php.net/manual/en/mongocursor.addoption.php

$this batchSize(integer $num)

Wrapper method for MongoCursor::batchSize().

Parameters

integer $num

Return Value

$this

See also

CursorInterface::batchSize()
http://php.net/manual/en/mongocursor.batchsize.php

integer count(boolean $foundOnly = false)

Wrapper method for MongoCursor::count().

Parameters

boolean $foundOnly

Return Value

integer

See also

CursorInterface::count()
http://php.net/manual/en/countable.count.php
http://php.net/manual/en/mongocursor.count.php

array|object|null current()

Wrapper method for MongoCursor::current().

If configured, the result may be a hydrated document class instance.

Return Value

array|object|null

See also

CursorInterface::current()
http://php.net/manual/en/iterator.current.php
http://php.net/manual/en/mongocursor.current.php

boolean dead()

Wrapper method for MongoCursor::dead().

Return Value

boolean

See also

CursorInterface::dead()
http://php.net/manual/en/mongocursor.dead.php

array explain()

Wrapper method for MongoCursor::explain().

Return Value

array

See also

CursorInterface::explain()
http://php.net/manual/en/mongocursor.explain.php

$this fields(array $f)

Wrapper method for MongoCursor::fields().

Parameters

array $f Fields to return (or not return).

Return Value

$this

See also

CursorInterface::fields()
http://php.net/manual/en/mongocursor.fields.php

array|object|null getNext()

Wrapper method for MongoCursor::getNext().

If configured, the result may be a hydrated document class instance.

Return Value

array|object|null

See also

CursorInterface::getNext()
http://php.net/manual/en/mongocursor.getnext.php

array getReadPreference()

Wrapper method for MongoCursor::getReadPreference().

Return Value

array

See also

CursorInterface::getReadPreference()
http://php.net/manual/en/mongocursor.getreadpreference.php

$this setReadPreference(string $readPreference, array $tags = null)

Wrapper method for MongoCursor::setReadPreference().

Parameters

string $readPreference
array $tags

Return Value

$this

See also

CursorInterface::setReadPreference()
http://php.net/manual/en/mongocursor.setreadpreference.php

array|object|null getSingleResult()

Reset the cursor and return its first result.

The cursor will be reset both before and after the single result is fetched. The original cursor limit (if any) will remain in place.

Return Value

array|object|null

See also

Iterator::getSingleResult()

getUseIdentifierKeys()

{@inheritDoc}

setUseIdentifierKeys($useIdentifierKeys)

{@inheritDoc}

Parameters

$useIdentifierKeys

hasNext()

{@inheritDoc}

$this hint(array|string $keyPattern)

Wrapper method for MongoCursor::hint().

This method is intended for setting MongoDB query hints, which are unrelated to UnitOfWork hints.

Parameters

array|string $keyPattern

Return Value

$this

See also

CursorInterface::hint()
http://php.net/manual/en/mongocursor.hint.php

$this hydrate(boolean $hydrate = true)

Set whether to hydrate results as document class instances.

Parameters

boolean $hydrate

Return Value

$this

$this immortal(boolean $liveForever = true)

Wrapper method for MongoCursor::immortal().

Parameters

boolean $liveForever

Return Value

$this

See also

CursorInterface::immortal()
http://php.net/manual/en/mongocursor.immortal.php

array info()

Wrapper method for MongoCursor::info().

Return Value

array

See also

CursorInterface::info()
http://php.net/manual/en/mongocursor.info.php

string key()

Wrapper method for MongoCursor::key().

$this limit(integer $num)

Wrapper method for MongoCursor::limit().

Parameters

integer $num

Return Value

$this

See also

CursorInterface::limit()
http://php.net/manual/en/mongocursor.limit.php

next()

Wrapper method for MongoCursor::next().

recreate()

Recreates the internal MongoCursor.

See also

CursorInterface::recreate()

$this refresh(boolean $refresh = true)

Set whether to refresh hydrated documents that are already in the identity map.

This option has no effect if hydration is disabled.

Parameters

boolean $refresh

Return Value

$this

reset()

Wrapper method for MongoCursor::reset().

rewind()

Wrapper method for MongoCursor::rewind().

$this skip(integer $num)

Wrapper method for MongoCursor::skip().

Parameters

integer $num

Return Value

$this

See also

CursorInterface::skip()
http://php.net/manual/en/mongocursor.skip.php

$this slaveOkay(boolean $ok = true)

Wrapper method for MongoCursor::slaveOkay().

Parameters

boolean $ok

Return Value

$this

See also

CursorInterface::slaveOkay()
http://php.net/manual/en/mongocursor.slaveokay.php

$this snapshot()

Wrapper method for MongoCursor::snapshot().

Return Value

$this

See also

CursorInterface::snapshot()
http://php.net/manual/en/mongocursor.snapshot.php

$this sort(array $fields)

Wrapper method for MongoCursor::sort().

Field names will be prepared according to the document mapping.

Parameters

array $fields

Return Value

$this

See also

CursorInterface::sort()
http://php.net/manual/en/mongocursor.sort.php

$this tailable(boolean $tail = true)

Wrapper method for MongoCursor::tailable().

Parameters

boolean $tail

Return Value

$this

See also

CursorInterface::tailable()
http://php.net/manual/en/mongocursor.tailable.php

$this timeout(integer $ms)

Wrapper method for MongoCursor::timeout().

Parameters

integer $ms

Return Value

$this

See also

CursorInterface::timeout()
http://php.net/manual/en/mongocursor.timeout.php

array toArray(boolean $useIdentifierKeys = null)

Return the cursor's results as an array.

If documents in the result set use BSON objects for their "_id", the $useKeys parameter may be set to false to avoid errors attempting to cast arrays (i.e. BSON objects) to string keys.

Parameters

boolean $useIdentifierKeys

Return Value

array

See also

Iterator::toArray()

boolean valid()

Wrapper method for MongoCursor::valid().

$this enableReferencePriming(array $primers, ReferencePrimer $referencePrimer)

Parameters

array $primers
ReferencePrimer $referencePrimer

Return Value

$this

protected primeReferences()

Prime references

protected primeReferencesForSingleResult(object $document)

Primes all references for a single document only. This avoids iterating over the entire cursor when getSingleResult() is called.

Parameters

object $document