Browse Source

Fixes #1638: prevent table names from being enclosed within curly brackets twice.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
2d3ac6b4e2
  1. 8
      framework/yii/db/ActiveQuery.php

8
framework/yii/db/ActiveQuery.php

@ -366,12 +366,18 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$parentTable = $this->getQueryTableName($parent); $parentTable = $this->getQueryTableName($parent);
$childTable = $this->getQueryTableName($child); $childTable = $this->getQueryTableName($child);
if (strpos($parentTable, '{{') === false) {
$parentTable = '{{' . $parentTable . '}}';
}
if (strpos($childTable, '{{') === false) {
$childTable = '{{' . $childTable . '}}';
}
if (!empty($child->link)) { if (!empty($child->link)) {
$on = []; $on = [];
foreach ($child->link as $childColumn => $parentColumn) { foreach ($child->link as $childColumn => $parentColumn) {
$on[] = '{{' . $parentTable . "}}.[[$parentColumn]] = {{" . $childTable . "}}.[[$childColumn]]"; $on[] = "$parentTable.[[$parentColumn]] = $childTable.[[$childColumn]]";
} }
$on = implode(' AND ', $on); $on = implode(' AND ', $on);
} else { } else {

Loading…
Cancel
Save