mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Moving 'joins' key conversion into DboSource::buildJoinStatement()
Having this in Model felt like the wrong layer for it to reside. This also simplifies a few things internally. Refs #1517
This commit is contained in:
parent
6afa21cb18
commit
d489d490a6
4 changed files with 10 additions and 11 deletions
|
@ -1297,7 +1297,7 @@ class DboSource extends DataSource {
|
|||
$query = array_merge(array('order' => $assocData['order'], 'limit' => $assocData['limit']), $query);
|
||||
} else {
|
||||
$join = array(
|
||||
'table' => $this->fullTableName($linkModel),
|
||||
'table' => $linkModel,
|
||||
'alias' => $alias,
|
||||
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
||||
'conditions' => trim($this->conditions($conditions, true, false, $model))
|
||||
|
@ -1336,7 +1336,7 @@ class DboSource extends DataSource {
|
|||
$joinKeys = array($assocData['foreignKey'], $assocData['associationForeignKey']);
|
||||
list($with, $joinFields) = $model->joinModel($assocData['with'], $joinKeys);
|
||||
|
||||
$joinTbl = $this->fullTableName($model->{$with});
|
||||
$joinTbl = $model->{$with};
|
||||
$joinAlias = $joinTbl;
|
||||
|
||||
if (is_array($joinFields) && !empty($joinFields)) {
|
||||
|
@ -1346,8 +1346,8 @@ class DboSource extends DataSource {
|
|||
$joinFields = array();
|
||||
}
|
||||
} else {
|
||||
$joinTbl = $this->fullTableName($assocData['joinTable']);
|
||||
$joinAlias = $joinTbl;
|
||||
$joinTbl = $assocData['joinTable'];
|
||||
$joinAlias = $this->fullTableName($assocData['joinTable']);
|
||||
}
|
||||
$query = array(
|
||||
'conditions' => $assocData['conditions'],
|
||||
|
@ -1436,6 +1436,9 @@ class DboSource extends DataSource {
|
|||
if (!empty($data['conditions'])) {
|
||||
$data['conditions'] = trim($this->conditions($data['conditions'], true, false));
|
||||
}
|
||||
if (!empty($data['table'])) {
|
||||
$data['table'] = $this->fullTableName($data['table']);
|
||||
}
|
||||
return $this->renderJoinStatement($data);
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1733,7 @@ class DboSource extends DataSource {
|
|||
if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig) {
|
||||
$assocData = $model->getAssociated($assoc);
|
||||
$join[] = $this->buildJoinStatement(array(
|
||||
'table' => $this->fullTableName($model->{$assoc}),
|
||||
'table' => $model->{$assoc},
|
||||
'alias' => $assoc,
|
||||
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
||||
'conditions' => trim($this->conditions(
|
||||
|
|
|
@ -2132,11 +2132,6 @@ class Model extends Overloadable {
|
|||
if (!$db =& ConnectionManager::getDataSource($this->useDbConfig)) {
|
||||
return false;
|
||||
}
|
||||
if (!empty($query['joins']) && is_array($query['joins'])) {
|
||||
foreach($query['joins'] as $i => $join) {
|
||||
$query['joins'][$i]['table'] = $db->fullTableName($join['table']);
|
||||
}
|
||||
}
|
||||
$results = $db->read($this, $query);
|
||||
$this->resetAssociations();
|
||||
|
||||
|
|
|
@ -1461,6 +1461,7 @@ class DboSourceTest extends CakeTestCase {
|
|||
'order' => array(),
|
||||
'group' => null
|
||||
);
|
||||
$queryData['joins'][0]['table'] = $this->testDb->fullTableName($queryData['joins'][0]['table']);
|
||||
$this->assertEqual($queryData, $expected);
|
||||
|
||||
$result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null);
|
||||
|
|
|
@ -5158,7 +5158,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'group' => null,
|
||||
'joins' => array(array(
|
||||
'alias' => 'ArticlesTag',
|
||||
'table' => $this->db->fullTableName('articles_tags'),
|
||||
'table' => 'articles_tags',
|
||||
'conditions' => array(
|
||||
array("ArticlesTag.article_id" => '{$__cakeID__$}'),
|
||||
array("ArticlesTag.tag_id" => $this->db->identifier('Tag.id'))
|
||||
|
|
Loading…
Reference in a new issue