mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
Fixing self association joins with conditions and fields
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4767 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ad2069af72
commit
ea144501ae
2 changed files with 13 additions and 8 deletions
|
@ -871,6 +871,11 @@ class DboSource extends DataSource {
|
||||||
'order' => $queryData['order']
|
'order' => $queryData['order']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!empty($assocData['conditions'])) {
|
||||||
|
$self['joins'][0]['conditions'] = preg_replace('/^\s*WHERE\s*/', '', trim($this->conditions(am($self['joins'][0]['conditions'], $assocData['conditions']))));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($queryData['joins'])) {
|
if (!empty($queryData['joins'])) {
|
||||||
foreach($queryData['joins'] as $join) {
|
foreach($queryData['joins'] as $join) {
|
||||||
$self['joins'][] = $join;
|
$self['joins'][] = $join;
|
||||||
|
@ -878,7 +883,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->__bypass === false) {
|
if($this->__bypass === false) {
|
||||||
$self['fields'] = am($self['fields'], $this->fields($linkModel, $alias, ''));
|
$self['fields'] = am($self['fields'], $this->fields($linkModel, $alias, (isset($assocData['fields']) ? $assocData['fields'] : '')));
|
||||||
}
|
}
|
||||||
$sql = $this->buildStatement($self, $model);
|
$sql = $this->buildStatement($self, $model);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue