Class ResultSet

Represents the results obtained after executing a query for a specific table This object is responsible for correctly nesting result keys reported from the query, casting each field to the correct type and executing the extra queries required for eager loading external associations.

Cake\ORM\ResultSet implements Cake\Datasource\ResultSetInterface uses Cake\Collection\CollectionTrait
Namespace: Cake\ORM
Located at ORM/ResultSet.php

Method Detail

__constructsource public

__construct( Cake\ORM\Query $query , Cake\Database\StatementInterface $statement )

Constructor

Parameters

Cake\ORM\Query $query
Query from where results come
Cake\Database\StatementInterface $statement
The statement to fetch from

__debugInfosource public

__debugInfo( )

Returns an array that can be used to describe the internal state of this object.

Returns

array
array

_calculateAssociationMapsource protected

_calculateAssociationMap( Cake\ORM\Query $query )

Calculates the list of associations that should get eager loaded when fetching each record

Parameters

Cake\ORM\Query $query
The query from where to derive the associations

_calculateColumnMapsource protected

_calculateColumnMap( Cake\ORM\Query $query )

Creates a map of row keys out of the query select clause that can be used to hydrate nested result sets more quickly.

Parameters

Cake\ORM\Query $query
The query from where to derive the column map

_calculateTypeMapsource protected

_calculateTypeMap( )

Creates a map of Type converter classes for each of the columns that should be fetched by this object.

_castValuessource protected

_castValues( string $alias , array $values )

Casts all values from a row brought from a table to the correct PHP type.

Parameters

string $alias
The table object alias
array $values
The values to cast

Returns

array
array

_fetchResultsource protected

_fetchResult( )

Helper function to fetch the next result from the statement or seeded results.

Returns

mixed
mixed

_getTypessource protected

_getTypes( Cake\ORM\Table $table , array $fields )

Returns the Type classes for each of the passed fields belonging to the table.

Parameters

Cake\ORM\Table $table
The table from which to get the schema
array $fields
The fields whitelist to use for fields in the schema.

Returns

array
array

_groupResultsource protected

_groupResult( mixed $row )

Correctly nests results keys including those coming from associations

Parameters

mixed $row
Array containing columns and values or false if there is no results

Returns

array
Results

countsource public

count( )

Gives the number of rows in the result set.

Part of the Countable interface.

Returns

integer
int

currentsource public

current( )

Returns the current record in the result iterator

Part of Iterator interface.

Returns

array|object
array|object

firstsource public

first( )

Get the first record from a result set.

This method will also close the underlying statement cursor.

Returns

array|object
array|object

Implementation of

Cake\Collection\CollectionInterface::first()

keysource public

key( )

Returns the key of the current record in the iterator

Part of Iterator interface.

Returns

integer
int

nextsource public

next( )

Advances the iterator pointer to the next record

Part of Iterator interface.

rewindsource public

rewind( )

Rewinds a ResultSet.

Part of Iterator interface.

Throws

Cake\Database\Exception
\Cake\Database\Exception

serializesource public

serialize( )

Serializes a resultset.

Part of Serializable interface.

Returns

string
Serialized object

unserializesource public

unserialize( string $serialized )

Unserializes a resultset.

Part of Serializable interface.

Parameters

string $serialized
Serialized object

validsource public

valid( )

Whether there are more results to be fetched from the iterator

Part of Iterator interface.

Returns

boolean
bool

Methods used from Cake\Collection\CollectionTrait

_unwrapsource public

_unwrap( )

Backwards compatible wrapper for unwrap()

Deprecated

Returns

Iterator
\Iterator

appendsource public

append( mixed $items )

Implementation of

Cake\Collection\CollectionInterface::append()

bufferedsource public

buffered( )

Returns

Cake\Collection\Iterator\BufferedIterator
\Cake\Collection\Iterator\BufferedIterator

Implementation of

Cake\Collection\CollectionInterface::buffered()

chunksource public

chunk( mixed $chunkSize )

Implementation of

Cake\Collection\CollectionInterface::chunk()

combinesource public

combine( mixed $keyPath , mixed $valuePath , mixed $groupPath null )

Implementation of

Cake\Collection\CollectionInterface::combine()

compilesource public

compile( mixed $preserveKeys true )

Implementation of

Cake\Collection\CollectionInterface::compile()

containssource public

contains( mixed $value )

Implementation of

Cake\Collection\CollectionInterface::contains()

countBysource public

countBy( mixed $callback )

Implementation of

Cake\Collection\CollectionInterface::countBy()

eachsource public

each( callable $c )

Implementation of

Cake\Collection\CollectionInterface::each()

everysource public

every( callable $c )

Implementation of

Cake\Collection\CollectionInterface::every()

extractsource public

extract( mixed $matcher )

Implementation of

Cake\Collection\CollectionInterface::extract()

filtersource public

filter( callable $c null )

Returns

Cake\Collection\Iterator\FilterIterator
\Cake\Collection\Iterator\FilterIterator

Implementation of

Cake\Collection\CollectionInterface::filter()

firstMatchsource public

firstMatch( array $conditions )

Implementation of

Cake\Collection\CollectionInterface::firstMatch()

groupBysource public

groupBy( mixed $callback )

Implementation of

Cake\Collection\CollectionInterface::groupBy()

indexBysource public

indexBy( mixed $callback )

Implementation of

Cake\Collection\CollectionInterface::indexBy()

insertsource public

insert( mixed $path , mixed $values )

Returns

Cake\Collection\Iterator\InsertIterator
\Cake\Collection\Iterator\InsertIterator

Implementation of

Cake\Collection\CollectionInterface::insert()

isEmptysource public

isEmpty( )

Implementation of

Cake\Collection\CollectionInterface::isEmpty()

jsonSerializesource public

jsonSerialize( )

Implementation of

Cake\Collection\CollectionInterface::jsonSerialize()

lastsource public

last( )

Implementation of

Cake\Collection\CollectionInterface::last()

listNestedsource public

listNested( mixed $dir 'desc' , mixed $nestingKey 'children' )

Returns

Cake\Collection\Iterator\TreeIterator
\Cake\Collection\Iterator\TreeIterator

Implementation of

Cake\Collection\CollectionInterface::listNested()

mapsource public

map( callable $c )

Returns

Cake\Collection\Iterator\ReplaceIterator
\Cake\Collection\Iterator\ReplaceIterator

Implementation of

Cake\Collection\CollectionInterface::map()

matchsource public

match( array $conditions )

Implementation of

Cake\Collection\CollectionInterface::match()

maxsource public

max( mixed $callback , mixed $type SORT_NUMERIC )

Implementation of

Cake\Collection\CollectionInterface::max()

minsource public

min( mixed $callback , mixed $type SORT_NUMERIC )

Implementation of

Cake\Collection\CollectionInterface::min()

nestsource public

nest( mixed $idPath , mixed $parentPath )

Implementation of

Cake\Collection\CollectionInterface::nest()

reducesource public

reduce( callable $c , mixed $zero null )

Implementation of

Cake\Collection\CollectionInterface::reduce()

rejectsource public

reject( callable $c )

Returns

Cake\Collection\Iterator\FilterIterator
\Cake\Collection\Iterator\FilterIterator

Implementation of

Cake\Collection\CollectionInterface::reject()

samplesource public

sample( mixed $size 10 )

Implementation of

Cake\Collection\CollectionInterface::sample()

shufflesource public

shuffle( )

Implementation of

Cake\Collection\CollectionInterface::shuffle()

skipsource public

skip( mixed $howMany )

Implementation of

Cake\Collection\CollectionInterface::skip()

somesource public

some( callable $c )

Implementation of

Cake\Collection\CollectionInterface::some()

sortBysource public

sortBy( mixed $callback , mixed $dir SORT_DESC , mixed $type SORT_NUMERIC )

Implementation of

Cake\Collection\CollectionInterface::sortBy()

stopWhensource public

stopWhen( mixed $condition )

Returns

Cake\Collection\Iterator\StoppableIterator
\Cake\Collection\Iterator\StoppableIterator

Implementation of

Cake\Collection\CollectionInterface::stopWhen()

sumOfsource public

sumOf( mixed $matcher null )

Implementation of

Cake\Collection\CollectionInterface::sumOf()

takesource public

take( mixed $size 1 , mixed $from 0 )

Implementation of

Cake\Collection\CollectionInterface::take()

throughsource public

through( callable $handler )

Implementation of

Cake\Collection\CollectionInterface::through()

toArraysource public

toArray( mixed $preserveKeys true )

Implementation of

Cake\Collection\CollectionInterface::toArray()

toListsource public

toList( )

Implementation of

Cake\Collection\CollectionInterface::toList()

unfoldsource public

unfold( callable $transformer null )

Implementation of

Cake\Collection\CollectionInterface::unfold()

unwrapsource public

unwrap( )

Implementation of

Cake\Collection\CollectionInterface::unwrap()

zipsource public

zip( mixed $items )

Implementation of

Cake\Collection\CollectionInterface::zip()

zipWithsource public

zipWith( mixed $items , mixed $callable )

Implementation of

Cake\Collection\CollectionInterface::zipWith()

Methods used from Cake\Collection\ExtractTrait

_createMatcherFiltersource protected

_createMatcherFilter( array $conditions )

Returns a callable that receives a value and will return whether or not it matches certain condition.

Parameters

array $conditions
A key-value list of conditions to match where the key is the property path to get from the current item and the value is the value to be compared the item with.

Returns

callable
callable

_extractsource protected

_extract( array|ArrayAccess $data , array $path )

Returns a column from $data that can be extracted by iterating over the column names contained in $path. It will return arrays for elements in represented with {*}

Parameters

array|ArrayAccess $data
Data.
array $path
Path to extract from.

Returns

mixed
mixed

_propertyExtractorsource protected

_propertyExtractor( string|callable $callback )

Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.

Parameters

string|callable $callback
A dot separated path of column to follow so that the final one can be returned or a callable that will take care of doing that.

Returns

callable
callable

_simpleExtractsource protected

_simpleExtract( array|ArrayAccess $data , array $path )

Returns a column from $data that can be extracted by iterating over the column names contained in $path

Parameters

array|ArrayAccess $data
Data.
array $path
Path to extract from.

Returns

mixed
mixed

Properties summary

$_containMapsource

protected array

List of associations that should be eager loaded.

[]

$_countsource

protected integer

Holds the count of records in this result set

$_currentsource

protected array

Last record fetched from the statement

$_defaultAliassource

protected string

The default table alias

$_defaultTablesource

protected Cake\ORM\Table

Default table instance

$_driversource

protected Cake\Database\Driver

The Database driver object.

Cached in a property to avoid multiple calls to the same function.

$_entityClasssource

protected string

The fully namespaced name of the class to use for hydrating results

$_hydratesource

protected boolean

Whether to hydrate results into objects or not

true

$_indexsource

protected integer

Points to the next record number that should be fetched

$_mapsource

protected array

Map of fields that are fetched from the statement with their type and the table they belong to

[]

$_matchingMapsource

protected array

List of associations that should be placed under the _matchingData result key.

[]

$_matchingMapColumnssource

protected array

List of matching associations and the column keys to expect from each of them.

[]

$_querysource

protected Cake\ORM\Query

Original query from where results were generated

Deprecated

3.1.6 Due to a memory leak, this property cannot be used anymore

$_resultssource

protected array|ArrayAccess

Results that have been fetched or hydrated into the results.

[]

$_statementsource

protected Cake\Database\StatementInterface

Database statement holding the results

$_typessource

protected array

Type cache for type converters.

Converters are indexed by alias and column name.

[]

$_useBufferingsource

protected boolean

Whether or not to buffer results fetched from the statement

true

© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.ORM.ResultSet.html