PHP Class Mongolid\Cursor\EmbeddedCursor

By doing this we can use '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
Afficher le fichier Open project: leroy-merlin-br/mongolid

Méthodes publiques

Свойство Type Description
$entityClass string Entity class that will be returned while iterating.

Protected Properties

Свойство Type Description
$items array The actual array of embedded documents.

Méthodes publiques

Méthode Description
__construct ( string $entityClass, array $items )
all ( ) : array Convert the cursor instance to an array of Items.
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).
first ( ) : mixed Returns the first element of the cursor.
key ( ) : integer Iterator key method (used in foreach).
limit ( integer $amount ) : EmbeddedCursor Limits the number of results returned.
next ( ) : void Iterator next method (used in foreach).
rewind ( ) : void Iterator interface rewind (used in foreach).
skip ( integer $amount ) : EmbeddedCursor Skips a number of results.
sort ( array $fields ) : EmbeddedCursor Sorts the results by given fields.
toArray ( ) : array Return the raw cursor items.
valid ( ) : boolean Iterator valid method (used in foreach).

Méthodes protégées

Méthode Description
getSchemaForEntity ( ) : Schema Retrieve a schema based on Entity Class.

Method Details

__construct() public méthode

public __construct ( string $entityClass, array $items )
$entityClass string Class of the objects that will be retrieved by the cursor.
$items array The items array.

all() public méthode

Convert the cursor instance to an array of Items.
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

first() public méthode

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

getSchemaForEntity() protected méthode

Retrieve a schema based on Entity Class.
protected getSchemaForEntity ( ) : Schema
Résultat Mongolid\Schema\Schema

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 ) : EmbeddedCursor
$amount integer The number of results to return.
Résultat EmbeddedCursor 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

skip() public méthode

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

sort() public méthode

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

toArray() public méthode

Return the raw cursor items.
public toArray ( ) : array
Résultat array

valid() public méthode

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

Property Details

$entityClass public_oe property

Entity class that will be returned while iterating.
public string $entityClass
Résultat string

$items protected_oe property

The actual array of embedded documents.
protected array $items
Résultat array