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:
phpnut 2007-04-05 00:47:17 +00:00
parent ad2069af72
commit ea144501ae
2 changed files with 13 additions and 8 deletions

View file

@ -871,6 +871,11 @@ class DboSource extends DataSource {
'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'])) {
foreach($queryData['joins'] as $join) {
$self['joins'][] = $join;
@ -878,7 +883,7 @@ class DboSource extends DataSource {
}
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);