mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Removing magic variable in DboSource to bypass the adding of fields to association queries, instead adding the ability to declare 'fields' => false in the association array. This opens the possibility of having joins for filtering purposes.
This commit is contained in:
parent
b22e30c5a3
commit
ee2930d3d0
1 changed files with 6 additions and 11 deletions
|
@ -195,14 +195,6 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
public $endQuote = null;
|
||||
|
||||
/**
|
||||
* Bypass automatic adding of joined fields/associations.
|
||||
*
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
private $__bypass = false;
|
||||
|
||||
/**
|
||||
* The set of valid SQL operations usable in a WHERE statement
|
||||
*
|
||||
|
@ -1036,7 +1028,7 @@ class DboSource extends DataSource {
|
|||
$null = null;
|
||||
$array = array();
|
||||
$linkedModels = array();
|
||||
$this->__bypass = false;
|
||||
$bypass = false;
|
||||
|
||||
if ($recursive === null && isset($queryData['recursive'])) {
|
||||
$recursive = $queryData['recursive'];
|
||||
|
@ -1048,7 +1040,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
if (!empty($queryData['fields'])) {
|
||||
$this->__bypass = true;
|
||||
$bypass = true;
|
||||
$queryData['fields'] = $this->fields($model, null, $queryData['fields']);
|
||||
} else {
|
||||
$queryData['fields'] = $this->fields($model);
|
||||
|
@ -1069,6 +1061,9 @@ class DboSource extends DataSource {
|
|||
|
||||
$linkModel->getDataSource();
|
||||
if ($model->useDbConfig === $linkModel->useDbConfig) {
|
||||
if ($bypass) {
|
||||
$assocData['fields'] = false;
|
||||
}
|
||||
if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
|
||||
$linkedModels[$type . '/' . $assoc] = true;
|
||||
}
|
||||
|
@ -1501,7 +1496,7 @@ class DboSource extends DataSource {
|
|||
$self = $model->name === $linkModel->name;
|
||||
$fields = array();
|
||||
|
||||
if ($external || (in_array($type, array('hasOne', 'belongsTo')) && $this->__bypass === false)) {
|
||||
if ($external || (in_array($type, array('hasOne', 'belongsTo')) && $assocData['fields'] !== false)) {
|
||||
$fields = $this->fields($linkModel, $association, $assocData['fields']);
|
||||
}
|
||||
if (empty($assocData['offset']) && !empty($assocData['page'])) {
|
||||
|
|
Loading…
Add table
Reference in a new issue