Index: t3lib/class.t3lib_sqlparser.php =================================================================== --- t3lib/class.t3lib_sqlparser.php (revision 6058) +++ t3lib/class.t3lib_sqlparser.php (working copy) @@ -817,7 +817,14 @@ // Looking for JOIN if ($join = $this->nextPart($parseString,'^(LEFT[[:space:]]+JOIN|LEFT[[:space:]]+OUTER[[:space:]]+JOIN|JOIN)[[:space:]]+')) { $stack[$pnt]['JOIN']['type'] = $join; - if ($stack[$pnt]['JOIN']['withTable'] = $this->nextPart($parseString,'^([[:alnum:]_]+)[[:space:]]+ON[[:space:]]+',1)) { + if ($stack[$pnt]['JOIN']['withTable'] = $this->nextPart($parseString,'^([[:alnum:]_]+)[[:space:]]+',1)) { + if (!preg_match('/^ON[[:space:]]+/i', $parseString)) { + $stack[$pnt]['JOIN']['as_keyword'] = $this->nextPart($parseString,'^(AS[[:space:]]+)'); + $stack[$pnt]['JOIN']['as'] = $this->nextPart($parseString,'^([[:alnum:]_]+)[[:space:]]+'); + } + if (!$this->nextPart($parseString, '^(ON[[:space:]]+)')) { + return $this->parseError('No join condition found in parseFromTables()!', $parseString); + } $field1 = $this->nextPart($parseString,'^([[:alnum:]_.]+)[[:space:]]*=[[:space:]]*',1); $field2 = $this->nextPart($parseString,'^([[:alnum:]_.]+)[[:space:]]+'); if ($field1 && $field2) { @@ -1533,7 +1540,12 @@ } if (is_array($v['JOIN'])) { - $outputParts[$k] .= ' '.$v['JOIN']['type'].' '.$v['JOIN']['withTable'].' ON '; + $outputParts[$k] .= ' ' . $v['JOIN']['type'] . ' ' . $v['JOIN']['withTable']; + // Add alias AS if there: + if ($v['JOIN']['as']) { + $outputParts[$k] .= ' ' . $v['JOIN']['as_keyword'] . ' ' . $v['JOIN']['as']; + } + $outputParts[$k] .= ' ON '; $outputParts[$k] .= ($v['JOIN']['ON'][0]['table']) ? $v['JOIN']['ON'][0]['table'].'.' : ''; $outputParts[$k] .= $v['JOIN']['ON'][0]['field']; $outputParts[$k] .= '='; @@ -1750,4 +1762,4 @@ include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlparser.php']); } -?> \ No newline at end of file +?>