mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding fixes for association conditions
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4763 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
06d6bbdbae
commit
cc46c03f31
2 changed files with 5 additions and 4 deletions
|
@ -994,16 +994,16 @@ class DboSource extends DataSource {
|
|||
}
|
||||
} else {
|
||||
if ($type == 'hasOne') {
|
||||
$conditions = array("{$alias}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$model->name}.{$model->primaryKey}" . ']__$}');
|
||||
$conditions = $this->__mergeConditions($queryData['conditions'], array("{$alias}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$model->name}.{$model->primaryKey}" . ']__$}'));
|
||||
} elseif ($type == 'belongsTo') {
|
||||
$conditions = array($model->escapeField($assocData['foreignKey']) => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}');
|
||||
$conditions = $this->__mergeConditions($assocData['conditions'], array($model->escapeField($assocData['foreignKey']) => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}'));
|
||||
}
|
||||
|
||||
$join = array(
|
||||
'table' => $this->fullTableName($linkModel),
|
||||
'alias' => $alias,
|
||||
'type' => 'LEFT',
|
||||
'conditions' => $conditions
|
||||
'conditions' => preg_replace('/^\s*WHERE\s*/', '', trim($this->conditions($conditions)))
|
||||
);
|
||||
$queryData['fields'] = am($queryData['fields'], $fields);
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ class DboSource extends DataSource {
|
|||
|
||||
function renderJoinStatement($data) {
|
||||
extract($data);
|
||||
return trim("{$type} JOIN {$table} {$alias} ON {$conditions}");
|
||||
return trim("{$type} JOIN {$table} {$alias} ON ({$conditions})");
|
||||
}
|
||||
|
||||
function renderStatement($data) {
|
||||
|
|
|
@ -662,6 +662,7 @@ class DboSourceTest extends UnitTestCase {
|
|||
'\s+ON\s+`Featured2`\.`article_featured2_id` = `ArticleFeatured2`\.`id`' .
|
||||
'\s+AND\s+`ArticleFeatured2`\.`published` = \'Y\'\s+' .
|
||||
'\s+WHERE\s+1\s+=\s+1\s*$/', $result);
|
||||
debug($result);
|
||||
}
|
||||
|
||||
function testGenerateAssociationQueryHasOne() {
|
||||
|
|
Loading…
Add table
Reference in a new issue