Skip to content

Commit

Permalink
Removing uses of db->fullTableName() when creating joins.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 7, 2011
1 parent 2fa2de4 commit 3becdc5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions cake/libs/model/behaviors/translate.php
Expand Up @@ -101,13 +101,16 @@ function beforeFind(&$model, $query) {
} else {
$tablePrefix = $db->config['prefix'];
}
$joinTable = new StdClass();
$joinTable->tablePrefix = $tablePrefix;
$joinTable->table = $RuntimeModel->table;

if (is_string($query['fields']) && 'COUNT(*) AS '.$db->name('count') == $query['fields']) {
$query['fields'] = 'COUNT(DISTINCT('.$db->name($model->alias . '.' . $model->primaryKey) . ')) ' . $db->alias . 'count';
$query['joins'][] = array(
'type' => 'INNER',
'alias' => $RuntimeModel->alias,
'table' => $db->name($tablePrefix . $RuntimeModel->useTable),
'table' => $joinTable,
'conditions' => array(
$model->alias . '.' . $model->primaryKey => $db->identifier($RuntimeModel->alias.'.foreign_key'),
$RuntimeModel->alias.'.model' => $model->name,
Expand Down Expand Up @@ -170,7 +173,7 @@ function beforeFind(&$model, $query) {
$query['joins'][] = array(
'type' => 'LEFT',
'alias' => 'I18n__'.$field.'__'.$_locale,
'table' => $db->name($tablePrefix . $RuntimeModel->useTable),
'table' => $joinTable,
'conditions' => array(
$model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}__{$_locale}.foreign_key"),
'I18n__'.$field.'__'.$_locale.'.model' => $model->name,
Expand All @@ -184,7 +187,7 @@ function beforeFind(&$model, $query) {
$query['joins'][] = array(
'type' => 'LEFT',
'alias' => 'I18n__'.$field,
'table' => $db->name($tablePrefix . $RuntimeModel->useTable),
'table' => $joinTable,
'conditions' => array(
$model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}.foreign_key"),
'I18n__'.$field.'.model' => $model->name,
Expand Down
6 changes: 3 additions & 3 deletions cake/libs/model/db_acl.php
Expand Up @@ -93,7 +93,7 @@ function node($ref = null) {
$db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")),
'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'),
'joins' => array(array(
'table' => $db->fullTableName($this),
'table' => $table,
'alias' => "{$type}0",
'type' => 'LEFT',
'conditions' => array("{$type}0.alias" => $start)
Expand All @@ -105,7 +105,7 @@ function node($ref = null) {
$j = $i - 1;

$queryData['joins'][] = array(
'table' => $db->fullTableName($this),
'table' => $table,
'alias' => "{$type}{$i}",
'type' => 'LEFT',
'conditions' => array(
Expand Down Expand Up @@ -175,7 +175,7 @@ function node($ref = null) {
'conditions' => $ref,
'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'),
'joins' => array(array(
'table' => $db->fullTableName($this),
'table' => $table,
'alias' => "{$type}0",
'type' => 'LEFT',
'conditions' => array(
Expand Down

0 comments on commit 3becdc5

Please sign in to comment.