PHP Class Doctrine\MongoDB\Query\Query

Since: 1.0
Author: Jonathan H. Wage ([email protected])
Author: Bulat Shakirzyanov ([email protected])
Inheritance: implements Doctrine\MongoDB\IteratorAggregate
Afficher le fichier Open project: doctrine/mongodb Class Usage Examples

Protected Properties

Свойство Type Description
$collection Doctrine\MongoDB\Collection The Collection instance.
$iterator Doctrine\MongoDB\Iterator
$options array Query options
$query array Query structure generated by the Builder class.

Méthodes publiques

Méthode Description
__construct ( Doctrine\MongoDB\Collection $collection, array $query, array $options ) Constructor.
count ( boolean $foundOnly = false ) : integer Count the number of results for this query.
debug ( string $name = null ) : mixed Return an array of information about the query structure for debugging.
execute ( ) : mixed Execute the query and return its result.
getIterator ( ) : Doctrine\MongoDB\Iterator Execute the query and return its result, which must be an Iterator.
getQuery ( ) : array Return the query structure.
getSingleResult ( ) : array | object | null Execute the query and return the first result.
getType ( ) : integer Return the query type.
iterate ( ) : Doctrine\MongoDB\Iterator Alias of {@link Query::getIterator()}.
toArray ( ) : array Execute the query and return its results as an array.

Méthodes protégées

Méthode Description
prepareCursor ( Doctrine\MongoDB\Cursor $cursor ) : Doctrine\MongoDB\CursorInterface Prepare the Cursor returned by {@link Query::execute()}.

Private Methods

Méthode Description
getQueryOptions ( ) : array Returns an array containing the specified keys and their values from the query array, provided they exist and are not null.
renameQueryOptions ( array $options, array $rename ) : array Returns an array with its keys renamed based on the translation map.
withReadPreference ( Doctrine\MongoDB\Database | Doctrine\MongoDB\Collection $object, Closure $closure ) : mixed Executes a closure with a temporary read preference on a database or collection.

Method Details

__construct() public méthode

Constructor.
public __construct ( Doctrine\MongoDB\Collection $collection, array $query, array $options )
$collection Doctrine\MongoDB\Collection
$query array
$options array

count() public méthode

If the query resulted in a Cursor, the $foundOnly parameter will ignore limit/skip values if false (the default). If the Query resulted in an EagerCursor or ArrayIterator, the $foundOnly parameter has no effect.
public count ( boolean $foundOnly = false ) : integer
$foundOnly boolean
Résultat integer

debug() public méthode

The $name parameter may be used to return a specific key from the internal $query array property. If omitted, the entire array will be returned.
public debug ( string $name = null ) : mixed
$name string
Résultat mixed

execute() public méthode

The return value will vary based on the query type. Commands with results (e.g. aggregate, inline mapReduce) may return an ArrayIterator. Other commands and operations may return a status array or a boolean, depending on the driver's write concern. Queries and some mapReduce commands will return a CursorInterface.
public execute ( ) : mixed
Résultat mixed

getIterator() public méthode

If the query type is not expected to return an Iterator, BadMethodCallException will be thrown before executing the query. Otherwise, the query will be executed and UnexpectedValueException will be thrown if {@link Query::execute()} does not return an Iterator.
See also: http://php.net/manual/en/iteratoraggregate.getiterator.php
public getIterator ( ) : Doctrine\MongoDB\Iterator
Résultat Doctrine\MongoDB\Iterator

getQuery() public méthode

Return the query structure.
public getQuery ( ) : array
Résultat array

getSingleResult() public méthode

Execute the query and return the first result.
See also: IteratorAggregate::getSingleResult()
public getSingleResult ( ) : array | object | null
Résultat array | object | null

getType() public méthode

Return the query type.
public getType ( ) : integer
Résultat integer

iterate() public méthode

Alias of {@link Query::getIterator()}.
Deprecation: 1.1 Use {@link Query::getIterator()}; will be removed for 2.0
public iterate ( ) : Doctrine\MongoDB\Iterator
Résultat Doctrine\MongoDB\Iterator

prepareCursor() protected méthode

This method will apply cursor options present in the query structure array. The Cursor may also be wrapped with an EagerCursor.
protected prepareCursor ( Doctrine\MongoDB\Cursor $cursor ) : Doctrine\MongoDB\CursorInterface
$cursor Doctrine\MongoDB\Cursor
Résultat Doctrine\MongoDB\CursorInterface

toArray() public méthode

Execute the query and return its results as an array.
See also: IteratorAggregate::toArray()
public toArray ( ) : array
Résultat array

Property Details

$collection protected_oe property

The Collection instance.
protected Collection,Doctrine\MongoDB $collection
Résultat Doctrine\MongoDB\Collection

$iterator protected_oe property

protected Iterator,Doctrine\MongoDB $iterator
Résultat Doctrine\MongoDB\Iterator

$options protected_oe property

Query options
protected array $options
Résultat array

$query protected_oe property

Query structure generated by the Builder class.
protected array $query
Résultat array