PHP Класс 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.
Наследование: implements Mongolid\Cursor\CursorInterface, implements Serializabl\Serializable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$entitySchema string Schema that describes the entity that will be retrieved when iterating through the cursor.

Защищенные свойства (Protected)

Свойство Тип Описание
$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).

Открытые методы

Метод Описание
__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).

Защищенные методы

Метод Описание
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.

Описание методов

__construct() публичный метод

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() публичный метод

Convert the cursor instance to an array of Objects.
public all ( ) : array
Результат array

count() публичный метод

Counts the number of results for this cursor.
public count ( ) : integer
Результат integer The number of documents returned by this cursor's query.

current() публичный метод

Iterator interface current. Return a model object with cursor document. (used in foreach).
public current ( ) : mixed
Результат mixed

disableTimeout() публичный метод

This method should be called before the cursor was started.
public disableTimeout ( boolean $flag = true ) : Cursor
$flag boolean Toggle timeout on or off.
Результат Cursor Returns this cursor.

first() публичный метод

Returns the first element of the cursor.
public first ( ) : mixed
Результат mixed

fresh() публичный метод

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
Результат void

getAssembler() защищенный метод

Retrieves an EntityAssembler instance.
protected getAssembler ( ) : EntityAssembler
Результат Mongolid\DataMapper\EntityAssembler

getConverter() защищенный метод

Converter is responsible to convert domain objects to mongo objects and vice versa.
protected getConverter ( ) : Converter
Результат Mongolid\Serializer\Type\Converter

getCursor() защищенный метод

If it does not exists yet, create it using the $collection, $command and $params given.
protected getCursor ( ) : Traversable
Результат Traversable

key() публичный метод

Iterator key method (used in foreach).
public key ( ) : integer
Результат integer

limit() публичный метод

Limits the number of results returned.
public limit ( integer $amount ) : Cursor
$amount integer The number of results to return.
Результат Cursor Returns this cursor.

next() публичный метод

Iterator next method (used in foreach).
public next ( ) : void
Результат void

rewind() публичный метод

Iterator interface rewind (used in foreach).
public rewind ( ) : void
Результат void

serialize() публичный метод

Serializes this object storing the collection name instead of the actual MongoDb\Collection (which is unserializable).
public serialize ( ) : string
Результат string Serialized object.

skip() публичный метод

Skips a number of results.
public skip ( integer $amount ) : Cursor
$amount integer The number of results to skip.
Результат Cursor Returns this cursor.

sort() публичный метод

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.
Результат Cursor Returns this cursor.

toArray() публичный метод

Convert the cursor instance to a full associative array.
public toArray ( ) : array
Результат array

unserialize() публичный метод

Unserializes this object. Re-creating the database connection.
public unserialize ( mixed $serialized ) : void
$serialized mixed Serialized cursor.
Результат void

valid() публичный метод

Iterator valid method (used in foreach).
public valid ( ) : boolean
Результат boolean

Описание свойств

$assembler защищенное свойство

Have the responsibility of assembling the data coming from the database into actual entities.
protected EntityAssembler,Mongolid\DataMapper $assembler
Результат Mongolid\DataMapper\EntityAssembler

$collection защищенное свойство

protected Collection,MongoDB $collection
Результат MongoDB\Collection

$command защищенное свойство

The command that is being called in the $collection.
protected string $command
Результат string

$converter защищенное свойство

Object responsible to convert domain objects to mongo objects and vice versa.
protected Converter,Mongolid\Serializer\Type $converter
Результат Mongolid\Serializer\Type\Converter

$cursor защищенное свойство

The MongoDB cursor used to interact with db.
protected Cursor,MongoDB\Driver $cursor
Результат MongoDB\Driver\Cursor

$entitySchema публичное свойство

Schema that describes the entity that will be retrieved when iterating through the cursor.
public string $entitySchema
Результат string

$params защищенное свойство

The parameters of the $command.
protected array $params
Результат array

$position защищенное свойство

Iterator position (to be used with foreach).
protected int $position
Результат integer