Skip to content

Commit

Permalink
Fixed sql syntax issue on QQCustomFrom clauses on queries with joins
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeho committed Jan 6, 2011
1 parent fcb76a0 commit 5a14068
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/qcodo/_core/framework/QQuery.class.php
Expand Up @@ -1529,10 +1529,10 @@ class QQueryBuilder extends QBaseClass {
protected $intColumnAliasCount = 0;
protected $strTableAliasArray;
protected $intTableAliasCount = 0;
protected $intCustomFromCount = 0;
protected $strFromArray;
protected $strJoinArray;
protected $strJoinConditionArray;
protected $strCustomFromArray;
protected $strWhereArray;
protected $strOrderByArray;
protected $strGroupByArray;
Expand Down Expand Up @@ -1579,7 +1579,8 @@ public function AddFromItem($strTableName, $strAliasOverride = null) {
$this->strEscapeIdentifierBegin, $strTableName, $this->strEscapeIdentifierEnd,
$this->strEscapeIdentifierBegin, $strTableAlias, $this->strEscapeIdentifierEnd);
} else {
$this->strFromArray[$strTableName . '+' . ($this->intCustomFromCount++)] = sprintf('%s%s%s AS %s%s%s',
// If an AliasOverride was submitted, we are doing a "custom from"
$this->strCustomFromArray[$strTableName . '+' . count($this->strCustomFromArray)] = sprintf('%s%s%s AS %s%s%s',
$this->strEscapeIdentifierBegin, $strTableName, $this->strEscapeIdentifierEnd,
$this->strEscapeIdentifierBegin, $strAliasOverride, $this->strEscapeIdentifierEnd);
}
Expand Down Expand Up @@ -1771,6 +1772,10 @@ public function GetStatement() {
implode(",\r\n ", $this->strFromArray),
implode("\r\n ", $this->strJoinArray));

// Custom "FROM" Columns
if (count($this->strCustomFromArray))
$strSql .= ",\r\n " . implode(",\r\n ", $this->strCustomFromArray);

// WHERE Clause
if (count($this->strWhereArray)) {
$strWhere = implode("\r\n ", $this->strWhereArray);
Expand Down

0 comments on commit 5a14068

Please sign in to comment.