mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Enabling join models for all DBOs
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4342 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
620f00adef
commit
1df76850c3
2 changed files with 10 additions and 12 deletions
|
@ -1057,14 +1057,12 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$joinFields = array();
|
||||
|
||||
if (isset($assocData['with']) && is_array($assocData['with']) && !empty($assocData['with'])) {
|
||||
$joinName = array_keys($assocData['with']);
|
||||
$joinFields = $assocData['with'][$joinName[0]];
|
||||
if (isset($assocData['with']) && !empty($assocData['with'])) {
|
||||
$joinFields = $model->{$assocData['with']}->loadInfo();
|
||||
$joinFields = $joinFields->extract('{n}.name');
|
||||
|
||||
if (is_array($joinFields) && !empty($joinFields)) {
|
||||
$joinFields = $this->fields($linkModel, $joinName[0], $joinFields);
|
||||
} else {
|
||||
$joinFields = array($this->name($joinName[0]) . '.*');
|
||||
$joinFields = $this->fields($model->{$assocData['with']}, $model->{$assocData['with']}->name, $joinFields);
|
||||
}
|
||||
}
|
||||
$sql .= ' ' . join(', ', am($this->fields($linkModel, $alias, $assocData['fields']), $joinFields));
|
||||
|
@ -1073,8 +1071,8 @@ class DboSource extends DataSource {
|
|||
|
||||
$joinAssoc = $joinTbl;
|
||||
|
||||
if (isset($assocData['with']) && is_array($assocData['with']) && !empty($assocData['with'])) {
|
||||
$joinAssoc = $joinName[0];
|
||||
if (isset($assocData['with']) && !empty($assocData['with'])) {
|
||||
$joinAssoc = $model->{$assocData['with']}->name;
|
||||
$sql .= $this->alias . $this->name($joinAssoc);
|
||||
}
|
||||
$sql .= ' ON ' . $this->name($joinAssoc);
|
||||
|
|
|
@ -556,7 +556,6 @@ class Model extends Overloadable {
|
|||
|
||||
// Convert all string-based associations to array based
|
||||
foreach($this->__associations as $type) {
|
||||
|
||||
if (!is_array($this->{$type})) {
|
||||
$this->{$type} = explode(',', $this->{$type});
|
||||
|
||||
|
@ -581,10 +580,11 @@ class Model extends Overloadable {
|
|||
$className = $value['className'];
|
||||
}
|
||||
$this->__constructLinkedModel($assoc, $className);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->__associations as $type) {
|
||||
if (isset($value['with']) && !empty($value['with'])) {
|
||||
$this->__constructLinkedModel($value['with'], $value['with']);
|
||||
}
|
||||
}
|
||||
$this->__generateAssociation($type);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue