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);
$childTable = $this->getQueryTableName($child);
if (strpos($parentTable, '{{') === false) {
$parentTable = '{{' . $parentTable . '}}';
}
if (strpos($childTable, '{{') === false) {
$childTable = '{{' . $childTable . '}}';
}
if (!empty($child->link)) {
$on = [];
foreach ($child->link as $childColumn => $parentColumn) {
$on[] = '{{' . $parentTable . "}}.[[$parentColumn]] = {{" . $childTable . "}}.[[$childColumn]]";
$on[] = "$parentTable.[[$parentColumn]] = $childTable.[[$childColumn]]";
}
$on = implode(' AND ', $on);
} else {

Loading…
Cancel
Save