mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Only generate query data for hasOne and belongsTo associations.
Avoid calling generateAssociationQuery(): * when the return value will never be usefull (True in this case) * to avoid polluting $queryData with uneeded fields Later, the SQL statement for the primary, and 'hasOne' plus 'belongsTo' relationships, is built.
This commit is contained in:
parent
2532228844
commit
c9e0131d6a
1 changed files with 7 additions and 0 deletions
|
@ -1056,7 +1056,12 @@ class DboSource extends DataSource {
|
|||
unset($_associations[2], $_associations[3]);
|
||||
}
|
||||
|
||||
// Generate hasOne and belongsTo associations inside $queryData
|
||||
foreach ($_associations as $type) {
|
||||
if ($type !== 'hasOne' && $type !== 'belongsTo') {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($model->{$type} as $assoc => $assocData) {
|
||||
$linkModel = $model->{$assoc};
|
||||
$external = isset($assocData['external']);
|
||||
|
@ -1073,6 +1078,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
|
||||
// Build SQL statement with the primary model, plus hasOne and belongsTo associations
|
||||
$query = $this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null);
|
||||
|
||||
$resultSet = $this->fetchAll($query, $model->cacheQueries);
|
||||
|
@ -1084,6 +1090,7 @@ class DboSource extends DataSource {
|
|||
|
||||
$filtered = array();
|
||||
|
||||
// Filter hasOne and belongsTo associations
|
||||
if ($queryData['callbacks'] === true || $queryData['callbacks'] === 'after') {
|
||||
$filtered = $this->_filterResults($resultSet, $model);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue