PHP Class JamesMoss\Flywheel\Result

A collection of Documents returned from a Query. This class acts like an array but also has some helper methods for manipulating the collection in useful ways.
Inheritance: implements IteratorAggregate, implements ArrayAccess, implements Countable
Afficher le fichier Open project: jamesmoss/flywheel Class Usage Examples

Protected Properties

Свойство Type Description
$documents
$total

Méthodes publiques

Méthode Description
__construct ( array $documents, integer $total ) Constructor
count ( ) : integer Returns the number of documents in this result
first ( ) : mixed Gets the first document from the result.
getIterator ( )
hash ( string $keyField, string $valueField ) : array Returns an assoiative array (a hash), where for each document the value of one property is the key, and another property is the value.
last ( ) : mixed Gets the last document from the results.
offsetExists ( $offset )
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
pick ( string $field ) : array Returns an array where each value is a single property from each document. If the property doesnt exist on the document then it won't be in the returned array.
total ( ) : integer Returns the total number of documents (if using limit in a query).
value ( $key ) : mixed Get the value specified by $key of the first object in the result.

Method Details

__construct() public méthode

Constructor
public __construct ( array $documents, integer $total )
$documents array An array of Documents
$total integer If this result only represents a small slice of the total (when using limit), this parameter represents the total number of documents.

count() public méthode

Returns the number of documents in this result
public count ( ) : integer
Résultat integer The number of documents

first() public méthode

Gets the first document from the result.
public first ( ) : mixed
Résultat mixed The first document, or false if the result is empty.

getIterator() public méthode

public getIterator ( )

hash() public méthode

Returns an assoiative array (a hash), where for each document the value of one property is the key, and another property is the value.
public hash ( string $keyField, string $valueField ) : array
$keyField string The name of the property to use for the key.
$valueField string Name of the property to use for the value.
Résultat array An associative array.

last() public méthode

Gets the last document from the results.
public last ( ) : mixed
Résultat mixed The last document, or false if the result is empty.

offsetExists() public méthode

public offsetExists ( $offset )

offsetGet() public méthode

public offsetGet ( $offset )

offsetSet() public méthode

public offsetSet ( $offset, $value )

offsetUnset() public méthode

public offsetUnset ( $offset )

pick() public méthode

Returns an array where each value is a single property from each document. If the property doesnt exist on the document then it won't be in the returned array.
public pick ( string $field ) : array
$field string The name of the field to pick.
Résultat array The array of values, one from each document.

total() public méthode

Useful for working out pagination.
public total ( ) : integer
Résultat integer The total number of documents

value() public méthode

Get the value specified by $key of the first object in the result.
public value ( $key ) : mixed
Résultat mixed The value, or false if there are no documents or the key doesnt exist.

Property Details

$documents protected_oe property

protected $documents

$total protected_oe property

protected $total