Skip to content
Permalink
Browse files

Removing uses of db->fullTableName() when creating joins.

Refs #2074
  • Loading branch information...
markstory committed Oct 7, 2011
1 parent 2fa2de4 commit 3becdc595960bdf297951aded5c677600f74e941
Showing with 9 additions and 6 deletions.
  1. +6 −3 cake/libs/model/behaviors/translate.php
  2. +3 −3 cake/libs/model/db_acl.php
@@ -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,
@@ -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,
@@ -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,
@@ -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)
@@ -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(
@@ -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(

0 comments on commit 3becdc5

Please sign in to comment.
You can’t perform that action at this time.