PHP Class Mongolid\Cursor\Cursor

By doing this we can, call 'sort', 'skip', 'limit' and others after calling 'where'. Because the mongodb library's MongoDB\Cursor is much more limited (in that regard) than the old driver MongoCursor.
Inheritance: implements Mongolid\Cursor\CursorInterface, implements Serializabl\Serializable
Afficher le fichier Open project: leroy-merlin-br/mongolid Class Usage Examples

Méthodes publiques

Свойство Type Description
$entitySchema string Schema that describes the entity that will be retrieved when iterating through the cursor.

Protected Properties

Свойство Type Description
$assembler Mongolid\DataMapper\EntityAssembler Have the responsibility of assembling the data coming from the database into actual entities.
$collection MongoDB\Collection
$command string The command that is being called in the $collection.
$converter Mongolid\Serializer\Type\Converter Object responsible to convert domain objects to mongo objects and vice versa.
$cursor MongoDB\Driver\Cursor The MongoDB cursor used to interact with db.
$params array The parameters of the $command.
$position integer Iterator position (to be used with foreach).

Méthodes publiques

Méthode Description
__construct ( Schema $entitySchema, MongoDB\Collection $collection, string $command, array $params )
all ( ) : array Convert the cursor instance to an array of Objects.
count ( ) : integer Counts the number of results for this cursor.
current ( ) : mixed Iterator interface current. Return a model object with cursor document. (used in foreach).
disableTimeout ( boolean $flag = true ) : Cursor Disable idle timeout of 10 minutes from MongoDB cursor.
first ( ) : mixed Returns the first element of the cursor.
fresh ( ) : void Refresh the cursor in order to be able to perform a rewind and iterate through it again. A new request to the database will be made in the next iteration.
key ( ) : integer Iterator key method (used in foreach).
limit ( integer $amount ) : Cursor Limits the number of results returned.
next ( ) : void Iterator next method (used in foreach).
rewind ( ) : void Iterator interface rewind (used in foreach).
serialize ( ) : string Serializes this object storing the collection name instead of the actual MongoDb\Collection (which is unserializable).
skip ( integer $amount ) : Cursor Skips a number of results.
sort ( array $fields ) : Cursor Sorts the results by given fields.
toArray ( ) : array Convert the cursor instance to a full associative array.
unserialize ( mixed $serialized ) : void Unserializes this object. Re-creating the database connection.
valid ( ) : boolean Iterator valid method (used in foreach).

Méthodes protégées

Méthode Description
getAssembler ( ) : EntityAssembler Retrieves an EntityAssembler instance.
getConverter ( ) : Converter Converter is responsible to convert domain objects to mongo objects and vice versa.
getCursor ( ) : Traversable Actually returns a Traversable object with the DriverCursor within.

Method Details

__construct() public méthode

public __construct ( Schema $entitySchema, MongoDB\Collection $collection, string $command, array $params )
$entitySchema Mongolid\Schema\Schema Schema that describes the entity that will be retrieved from the database.
$collection MongoDB\Collection The raw collection object that will be used to retrieve the documents.
$command string The command that is being called in the $collection.
$params array The parameters of the $command.

all() public méthode

Convert the cursor instance to an array of Objects.
public all ( ) : array
Résultat array

count() public méthode

Counts the number of results for this cursor.
public count ( ) : integer
Résultat integer The number of documents returned by this cursor's query.

current() public méthode

Iterator interface current. Return a model object with cursor document. (used in foreach).
public current ( ) : mixed
Résultat mixed

disableTimeout() public méthode

This method should be called before the cursor was started.
public disableTimeout ( boolean $flag = true ) : Cursor
$flag boolean Toggle timeout on or off.
Résultat Cursor Returns this cursor.

first() public méthode

Returns the first element of the cursor.
public first ( ) : mixed
Résultat mixed

fresh() public méthode

Refresh the cursor in order to be able to perform a rewind and iterate through it again. A new request to the database will be made in the next iteration.
public fresh ( ) : void
Résultat void

getAssembler() protected méthode

Retrieves an EntityAssembler instance.
protected getAssembler ( ) : EntityAssembler
Résultat Mongolid\DataMapper\EntityAssembler

getConverter() protected méthode

Converter is responsible to convert domain objects to mongo objects and vice versa.
protected getConverter ( ) : Converter
Résultat Mongolid\Serializer\Type\Converter

getCursor() protected méthode

If it does not exists yet, create it using the $collection, $command and $params given.
protected getCursor ( ) : Traversable
Résultat Traversable

key() public méthode

Iterator key method (used in foreach).
public key ( ) : integer
Résultat integer

limit() public méthode

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

next() public méthode

Iterator next method (used in foreach).
public next ( ) : void
Résultat void

rewind() public méthode

Iterator interface rewind (used in foreach).
public rewind ( ) : void
Résultat void

serialize() public méthode

Serializes this object storing the collection name instead of the actual MongoDb\Collection (which is unserializable).
public serialize ( ) : string
Résultat string Serialized object.

skip() public méthode

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

sort() public méthode

Sorts the results by given fields.
public sort ( array $fields ) : Cursor
$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 Cursor Returns this cursor.

toArray() public méthode

Convert the cursor instance to a full associative array.
public toArray ( ) : array
Résultat array

unserialize() public méthode

Unserializes this object. Re-creating the database connection.
public unserialize ( mixed $serialized ) : void
$serialized mixed Serialized cursor.
Résultat void

valid() public méthode

Iterator valid method (used in foreach).
public valid ( ) : boolean
Résultat boolean

Property Details

$assembler protected_oe property

Have the responsibility of assembling the data coming from the database into actual entities.
protected EntityAssembler,Mongolid\DataMapper $assembler
Résultat Mongolid\DataMapper\EntityAssembler

$collection protected_oe property

protected Collection,MongoDB $collection
Résultat MongoDB\Collection

$command protected_oe property

The command that is being called in the $collection.
protected string $command
Résultat string

$converter protected_oe property

Object responsible to convert domain objects to mongo objects and vice versa.
protected Converter,Mongolid\Serializer\Type $converter
Résultat Mongolid\Serializer\Type\Converter

$cursor protected_oe property

The MongoDB cursor used to interact with db.
protected Cursor,MongoDB\Driver $cursor
Résultat MongoDB\Driver\Cursor

$entitySchema public_oe property

Schema that describes the entity that will be retrieved when iterating through the cursor.
public string $entitySchema
Résultat string

$params protected_oe property

The parameters of the $command.
protected array $params
Résultat array

$position protected_oe property

Iterator position (to be used with foreach).
protected int $position
Résultat integer