class Query extends Query (View source)

ODM Query wraps the raw Doctrine MongoDB queries to add additional functionality and to hydrate the raw arrays of data to Doctrine document objects.

Constants

HINT_REFRESH

HINT_SLAVE_OKAY

HINT_READ_PREFERENCE

HINT_READ_PREFERENCE_TAGS

Methods

__construct(DocumentManager $dm, ClassMetadata $class, Collection $collection, array $query = array(), array $options = array(), boolean $hydrate = true, boolean $refresh = false, array $primers = array(), null $requireIndexes = null)

Constructor.

getDocumentManager()

Gets the DocumentManager instance.

getClass()

Gets the ClassMetadata instance.

setHydrate(boolean $hydrate)

Sets whether or not to hydrate the documents to objects.

setRefresh(boolean $refresh)

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

array
getFieldsInQuery()

Gets the fields involved in this query.

bool
isIndexed()

Check if this query is indexed.

array
getUnindexedFields()

Gets an array of the unindexed fields in this query.

mixed
execute()

Execute the query and returns the results.

CursorInterface
prepareCursor(Cursor $cursor)

Prepare the Cursor returned by {@link Query::execute()}.

Details

__construct(DocumentManager $dm, ClassMetadata $class, Collection $collection, array $query = array(), array $options = array(), boolean $hydrate = true, boolean $refresh = false, array $primers = array(), null $requireIndexes = null)

Constructor.

Parameters

DocumentManager $dm
ClassMetadata $class
Collection $collection
array $query
array $options
boolean $hydrate
boolean $refresh
array $primers
null $requireIndexes

DocumentManager getDocumentManager()

Gets the DocumentManager instance.

Return Value

DocumentManager $dm

ClassMetadata getClass()

Gets the ClassMetadata instance.

Return Value

ClassMetadata $class

setHydrate(boolean $hydrate)

Sets whether or not to hydrate the documents to objects.

Parameters

boolean $hydrate

setRefresh(boolean $refresh)

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

array getFieldsInQuery()

Gets the fields involved in this query.

Return Value

array $fields An array of fields names used in this query.

bool isIndexed()

Check if this query is indexed.

Return Value

bool

array getUnindexedFields()

Gets an array of the unindexed fields in this query.

Return Value

array

mixed execute()

Execute the query and returns the results.

Return Value

mixed

Exceptions

MongoDBException

protected CursorInterface prepareCursor(Cursor $cursor)

Prepare the Cursor returned by {@link Query::execute()}.

This method will wrap the base Cursor with an ODM Cursor or EagerCursor, and set the hydrate option and UnitOfWork hints. This occurs in addition to any preparation done by the base Query class.

Parameters

Cursor $cursor

Return Value

CursorInterface

See also

\Doctrine\MongoDB\Cursor::prepareCursor()