Index: t3lib/class.t3lib_sqlparser.php =================================================================== --- t3lib/class.t3lib_sqlparser.php (revision 6162) +++ t3lib/class.t3lib_sqlparser.php (working copy) @@ -815,12 +815,13 @@ } else return $this->parseError('No table name found as expected in parseFromTables()!',$parseString); // 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:]]+', 1)) { + $joinCnt = 0; + while ($join = $this->nextPart($parseString,'^(LEFT[[:space:]]+JOIN|LEFT[[:space:]]+OUTER[[:space:]]+JOIN|INNER[[:space:]]+JOIN|JOIN)[[:space:]]+')) { + $stack[$pnt]['JOIN'][$joinCnt]['type'] = $join; + if ($stack[$pnt]['JOIN'][$joinCnt]['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:]]+'); + $stack[$pnt]['JOIN'][$joinCnt]['as_keyword'] = $this->nextPart($parseString, '^(AS[[:space:]]+)'); + $stack[$pnt]['JOIN'][$joinCnt]['as'] = $this->nextPart($parseString, '^([[:alnum:]_]+)[[:space:]]+'); } if (!$this->nextPart($parseString, '^(ON[[:space:]]+)')) { return $this->parseError('No join condition found in parseFromTables()!', $parseString); @@ -848,7 +849,8 @@ $field2['table'] = $tableField[0]; $field2['field'] = $tableField[1]; } - $stack[$pnt]['JOIN']['ON'] = array($field1,$field2); + $stack[$pnt]['JOIN'][$joinCnt]['ON'] = array($field1,$field2); + $joinCnt++; } else return $this->parseError('No join fields found in parseFromTables()!',$parseString); } else return $this->parseError('No join table found in parseFromTables()!',$parseString); } @@ -1540,17 +1542,19 @@ } if (is_array($v['JOIN'])) { - $outputParts[$k] .= ' ' . $v['JOIN']['type'] . ' ' . $v['JOIN']['withTable']; - // Add alias AS if there: - if (isset($v['JOIN']['as']) && $v['JOIN']['as']) { - $outputParts[$k] .= ' ' . $v['JOIN']['as_keyword'] . ' ' . $v['JOIN']['as']; + foreach ($v['JOIN'] as $join) { + $outputParts[$k] .= ' ' . $join['type'] . ' ' . $join['withTable']; + // Add alias AS if there: + if (isset($join['as']) && $join['as']) { + $outputParts[$k] .= ' ' . $join['as_keyword'] . ' ' . $join['as']; + } + $outputParts[$k] .= ' ON '; + $outputParts[$k] .= ($join['ON'][0]['table']) ? $join['ON'][0]['table'].'.' : ''; + $outputParts[$k] .= $join['ON'][0]['field']; + $outputParts[$k] .= '='; + $outputParts[$k] .= ($join['ON'][1]['table']) ? $join['ON'][1]['table'].'.' : ''; + $outputParts[$k] .= $join['ON'][1]['field']; } - $outputParts[$k] .= ' ON '; - $outputParts[$k] .= ($v['JOIN']['ON'][0]['table']) ? $v['JOIN']['ON'][0]['table'].'.' : ''; - $outputParts[$k] .= $v['JOIN']['ON'][0]['field']; - $outputParts[$k] .= '='; - $outputParts[$k] .= ($v['JOIN']['ON'][1]['table']) ? $v['JOIN']['ON'][1]['table'].'.' : ''; - $outputParts[$k] .= $v['JOIN']['ON'][1]['field']; } } }