Implements the logic for loading an association using a SELECT query and a pivot table
string
The alias of the association loading the results
string
The type of the association triggering the load
string
The binding key for the source association.
callable
A callable that will return a query object used for loading the association results
array|string
The foreignKey to the target association
Cake\ORM\Association\HasMany
The junction association instance
string
The name of the junction association
Cake\Database\ExpressionInterfaceClosure|array|string|null
Custom conditions for the junction association
string
The property name for the junction association, where its results should be nested at.
string
The sorting options for loading the association
string
The alias of the source association
string
The strategy to use for loading, either select or subquery
string
The alias of the target association
Copies the options array to properties in this class. The keys in the array correspond to properties in this class.
Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values.
Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values when the filtering needs to be done using a subquery.
Checks that the fetching query either has auto fields on or has the foreignKey fields selected. If the required fields are missing, throws an exception.
Auxiliary function to construct a new Query object to return all the records in the target table that are associated to those specified in $options from the source table.
Builds an array containing the results from fetchQuery indexed by the foreignKey value corresponding to this association.
Builds a query to be used as a condition for filtering records in the target table, it is constructed by cloning the original query that was used to load records in the source table.
Returns a TupleComparison object that can be used for matching all the fields from $keys with the tuple values in $filter using the provided operator.
Returns the default options to use for the eagerLoader
Helper method to infer the requested finder and its options.
Generates a string used as a table field that contains the values upon which the filter should be applied
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows when the matching needs to be done with multiple foreign keys
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows
Calculate the fields that need to participate in a subquery.
Returns a callable that can be used for injecting association results into a given iterator. The options accepted by this method are the same as Association::eagerLoader()
__construct(array<string, mixed> $options)
Copies the options array to properties in this class. The keys in the array correspond to properties in this class.
array<string, mixed>
$options _addFilteringCondition(Cake\ORM\Query $query, array<string>|string $key, mixed $filter): Cake\ORM\Query
Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values.
Cake\ORM\Query
$query Target table's query
array<string>|string
$key The fields that should be used for filtering
mixed
$filter The value that should be used to match for $key
Cake\ORM\Query
_addFilteringJoin(Cake\ORM\Query $query, array<string>|string $key, Cake\ORM\Query $subquery): Cake\ORM\Query
Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values when the filtering needs to be done using a subquery.
Cake\ORM\Query
$query Target table's query
array<string>|string
$key the fields that should be used for filtering
Cake\ORM\Query
$subquery The Subquery to use for filtering
Cake\ORM\Query
_assertFieldsPresent(Cake\ORM\Query $fetchQuery, array<string> $key): void
Checks that the fetching query either has auto fields on or has the foreignKey fields selected. If the required fields are missing, throws an exception.
Cake\ORM\Query
$fetchQuery array<string>
$key void
_buildQuery(array<string, mixed> $options): Cake\ORM\Query
Auxiliary function to construct a new Query object to return all the records in the target table that are associated to those specified in $options from the source table.
This is used for eager loading records on the target table based on conditions.
array<string, mixed>
$options options accepted by eagerLoader()
Cake\ORM\Query
InvalidArgumentException
_buildResultMap(Cake\ORM\Query $fetchQuery, array<string, mixed> $options): array<string, mixed>
Builds an array containing the results from fetchQuery indexed by the foreignKey value corresponding to this association.
Cake\ORM\Query
$fetchQuery The query to get results from
array<string, mixed>
$options The options passed to the eager loader
array<string, mixed>
RuntimeException
_buildSubquery(Cake\ORM\Query $query): Cake\ORM\Query
Builds a query to be used as a condition for filtering records in the target table, it is constructed by cloning the original query that was used to load records in the source table.
Cake\ORM\Query
$query the original query used to load source records
Cake\ORM\Query
_createTupleCondition(Cake\ORM\Query $query, array<string> $keys, mixed $filter, string $operator): Cake\Database\Expression\TupleComparison
Returns a TupleComparison object that can be used for matching all the fields from $keys with the tuple values in $filter using the provided operator.
Cake\ORM\Query
$query Target table's query
array<string>
$keys the fields that should be used for filtering
mixed
$filter the value that should be used to match for $key
string
$operator The operator for comparing the tuples
Cake\Database\Expression\TupleComparison
_defaultOptions(): array<string, mixed>
Returns the default options to use for the eagerLoader
array<string, mixed>
_extractFinder(array|string $finderData): array
Helper method to infer the requested finder and its options.
Returns the inferred options from the finder $type.
The following will call the finder 'translations' with the value of the finder as its options: $query->contain(['Comments' => ['finder' => ['translations']]]); $query->contain(['Comments' => ['finder' => ['translations' => []]]]); $query->contain(['Comments' => ['finder' => ['translations' => ['locales' => ['en_US']]]]]);
array|string
$finderData The finder name or an array having the name as key and options as value.
array
_linkField(array<string, mixed> $options): array<string>|string
Generates a string used as a table field that contains the values upon which the filter should be applied
array<string, mixed>
$options the options to use for getting the link field.
array<string>|string
_multiKeysInjector(array<string, mixed> $resultMap, array<string> $sourceKeys, string $nestKey): Closure
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows when the matching needs to be done with multiple foreign keys
array<string, mixed>
$resultMap A keyed arrays containing the target table
array<string>
$sourceKeys An array with aliased keys to match
string
$nestKey The key under which results should be nested
Closure
_resultInjector(Cake\ORM\Query $fetchQuery, array<string, mixed> $resultMap, array<string, mixed> $options): Closure
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows
Cake\ORM\Query
$fetchQuery the Query used to fetch results
array<string, mixed>
$resultMap an array with the foreignKey as keys and the corresponding target table results as value.
array<string, mixed>
$options The options passed to the eagerLoader method
Closure
_subqueryFields(Cake\ORM\Query $query): array<string, array>
Calculate the fields that need to participate in a subquery.
Normally this includes the binding key columns. If there is a an ORDER BY, those columns are also included as the fields may be calculated or constant values, that need to be present to ensure the correct association data is loaded.
Cake\ORM\Query
$query The query to get fields from.
array<string, array>
buildEagerLoader(array<string, mixed> $options): Closure
Returns a callable that can be used for injecting association results into a given iterator. The options accepted by this method are the same as Association::eagerLoader()
array<string, mixed>
$options Same options as Association::eagerLoader()
Closure
The alias of the association loading the results
string
The type of the association triggering the load
string
The binding key for the source association.
string
A callable that will return a query object used for loading the association results
callable
The foreignKey to the target association
array|string
The junction association instance
Cake\ORM\Association\HasMany
The name of the junction association
string
Custom conditions for the junction association
Cake\Database\ExpressionInterfaceClosure|array|string|null
The property name for the junction association, where its results should be nested at.
string
The sorting options for loading the association
string
The alias of the source association
string
The strategy to use for loading, either select or subquery
string
The alias of the target association
string
© 2005–present 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.
https://api.cakephp.org/4.4/class-Cake.ORM.Association.Loader.SelectWithPivotLoader.html