From 3becdc595960bdf297951aded5c677600f74e941 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 6 Oct 2011 20:34:23 -0400 Subject: [PATCH] Removing uses of db->fullTableName() when creating joins. Refs #2074 --- cake/libs/model/behaviors/translate.php | 9 ++++++--- cake/libs/model/db_acl.php | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 3e92c4112..b0546bb54 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -101,13 +101,16 @@ class TranslateBehavior extends ModelBehavior { } 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, @@ -170,7 +173,7 @@ class TranslateBehavior extends ModelBehavior { $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, @@ -184,7 +187,7 @@ class TranslateBehavior extends ModelBehavior { $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, diff --git a/cake/libs/model/db_acl.php b/cake/libs/model/db_acl.php index 0008a3919..b49a6f634 100644 --- a/cake/libs/model/db_acl.php +++ b/cake/libs/model/db_acl.php @@ -93,7 +93,7 @@ class AclNode extends AppModel { $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) @@ -105,7 +105,7 @@ class AclNode extends AppModel { $j = $i - 1; $queryData['joins'][] = array( - 'table' => $db->fullTableName($this), + 'table' => $table, 'alias' => "{$type}{$i}", 'type' => 'LEFT', 'conditions' => array( @@ -175,7 +175,7 @@ class AclNode extends AppModel { '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(