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
Properties summary
-
$_autoFields
protectedboolean
Tracks value of $_autoFields property of $query passed to constructor. -
$_containMap
protectedarray
List of associations that should be eager loaded. -
$_count
protectedinteger
Holds the count of records in this result set -
$_current
protectedarray
Last record fetched from the statement -
$_defaultAlias
protectedstring
The default table alias -
$_defaultTable
protectedDefault table instance -
$_driver
protectedThe Database driver object. -
$_entityClass
protectedstring
The fully namespaced name of the class to use for hydrating results -
$_hydrate
protectedboolean
Whether to hydrate results into objects or not -
$_index
protectedinteger
Points to the next record number that should be fetched -
$_map
protectedarray
Map of fields that are fetched from the statement with their type and the table they belong to
-
$_matchingMap
protectedarray
List of associations that should be placed under the
_matchingData
result key. -
$_matchingMapColumns
protectedarray
List of matching associations and the column keys to expect from each of them.
-
$_query
protectedOriginal query from where results were generated -
$_results
protectedarray|ArrayAccess
Results that have been fetched or hydrated into the results. -
$_statement
protectedDatabase statement holding the results -
$_types
protectedarray
Type cache for type converters. -
$_useBuffering
protectedboolean
Whether or not to buffer results fetched from the statement
Method Summary
-
__construct() public
Constructor -
__debugInfo() public
Returns an array that can be used to describe the internal state of this object.
-
_calculateAssociationMap() protected
Calculates the list of associations that should get eager loaded when fetching each record
-
_calculateColumnMap() protected
Creates a map of row keys out of the query select clause that can be used to hydrate nested result sets more quickly.
-
_calculateTypeMap() protected
Creates a map of Type converter classes for each of the columns that should be fetched by this object.
-
_castValues() protected
Casts all values from a row brought from a table to the correct PHP type.
-
_fetchResult() protected
Helper function to fetch the next result from the statement or seeded results.
-
_getTypes() protected
Returns the Type classes for each of the passed fields belonging to the table.
-
_groupResult() protected
Correctly nests results keys including those coming from associations -
count() public
Gives the number of rows in the result set. -
current() public
Returns the current record in the result iterator -
first() public
Get the first record from a result set. -
key() public
Returns the key of the current record in the iterator -
next() public
Advances the iterator pointer to the next record -
rewind() public
Rewinds a ResultSet. -
serialize() public
Serializes a resultset. -
unserialize() public
Unserializes a resultset. -
valid() public
Whether there are more results to be fetched from the iterator
Method Detail
__construct() 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
__debugInfo() public ¶
__debugInfo( )
Returns an array that can be used to describe the internal state of this object.
Returns
_calculateAssociationMap() 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
_calculateColumnMap() 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
_calculateTypeMap() protected ¶
_calculateTypeMap( )
Creates a map of Type converter classes for each of the columns that should be fetched by this object.
Deprecated
_castValues() protected ¶
_castValues( string $alias , array $values )
Casts all values from a row brought from a table to the correct PHP type.
Deprecated
Parameters
- string $alias
- The table object alias
- array $values
- The values to cast
Returns
_fetchResult() protected ¶
_fetchResult( )
Helper function to fetch the next result from the statement or seeded results.
Returns
_getTypes() 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
_groupResult() protected ¶
_groupResult( array $row )
Correctly nests results keys including those coming from associations
Parameters
- array $row
- Array containing columns and values or false if there is no results
Returns
Results
count() public ¶
count( )
Gives the number of rows in the result set.
Part of the Countable interface.
Returns
Implementation of
current() public ¶
current( )
Returns the current record in the result iterator
Part of Iterator interface.
Returns
Implementation of
Iterator::current()
first() public ¶
first( )
Get the first record from a result set.
This method will also close the underlying statement cursor.
Returns
Implementation of
key() public ¶
key( )
Returns the key of the current record in the iterator
Part of Iterator interface.
Returns
Implementation of
Iterator::key()
next() public ¶
next( )
Advances the iterator pointer to the next record
Part of Iterator interface.
Implementation of
Iterator::next()
rewind() public ¶
rewind( )
Rewinds a ResultSet.
Part of Iterator interface.
Throws
Implementation of
Iterator::rewind()
serialize() public ¶
serialize( )
Serializes a resultset.
Part of Serializable interface.
Returns
Serialized object
Implementation of
Serializable::serialize()
unserialize() public ¶
unserialize( string $serialized )
Unserializes a resultset.
Part of Serializable interface.
Parameters
- string $serialized
- Serialized object
Implementation of
Serializable::unserialize()
Methods used from Cake\Collection\CollectionTrait
cartesianProduct() public ¶
cartesianProduct( callable $operation null , callable $filter null )
Parameters
- callable $operation optional null
- Operation
- callable $filter optional null
- Filter
Returns
Throws
optimizeUnwrap() protected ¶
optimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
Returns
Magic methods inherited from Cake\Collection\CollectionInterface
cartesianProduct()
|
Properties detail
$_autoFields ¶
Tracks value of $_autoFields property of $query passed to constructor.
$_driver ¶
Cake\Database\Driver
The Database driver object.
Cached in a property to avoid multiple calls to the same function.
$_entityClass ¶
The fully namespaced name of the class to use for hydrating results
$_map ¶
Map of fields that are fetched from the statement with their type and the table they belong to
[]
$_matchingMap ¶
List of associations that should be placed under the _matchingData
result key.
[]
$_matchingMapColumns ¶
List of matching associations and the column keys to expect from each of them.
[]
$_query ¶
Cake\ORM\Query
Original query from where results were generated
Deprecated
$_results ¶
Results that have been fetched or hydrated into the results.
[]