/**
  * Compiles a "SELECT [output] FROM..:" field list based on input array (made with ->parseFieldList())
  * Can also compile field lists for ORDER BY and GROUP BY.
  *
  * @param	array		Array of select fields, (made with ->parseFieldList())
  * @param	boolean		Whether comments should be compiled
  * @param	boolean		Whether function mapping should take place
  * @return	string		Select field string
  * @see parseFieldList()
  */
 public function compileFieldList($selectFields, $compileComments = TRUE, $functionMapping = TRUE)
 {
     switch ((string) $GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type']) {
         case 'native':
             $output = parent::compileFieldList($selectFields, $compileComments);
             break;
         case 'adodb':
             $output = '';
             // Traverse the selectFields if any:
             if (is_array($selectFields)) {
                 $outputParts = array();
                 foreach ($selectFields as $k => $v) {
                     // Detecting type:
                     switch ($v['type']) {
                         case 'function':
                             $outputParts[$k] = $v['function'] . '(' . $v['func_content'] . ')';
                             break;
                         case 'flow-control':
                             if ($v['flow-control']['type'] === 'CASE') {
                                 $outputParts[$k] = $this->compileCaseStatement($v['flow-control'], $functionMapping);
                             }
                             break;
                         case 'field':
                             $outputParts[$k] = ($v['distinct'] ? $v['distinct'] : '') . ($v['table'] ? $v['table'] . '.' : '') . $v['field'];
                             break;
                     }
                     // Alias:
                     if ($v['as']) {
                         $outputParts[$k] .= ' ' . $v['as_keyword'] . ' ' . $v['as'];
                     }
                     // Specifically for ORDER BY and GROUP BY field lists:
                     if ($v['sortDir']) {
                         $outputParts[$k] .= ' ' . $v['sortDir'];
                     }
                 }
                 // TODO: Handle SQL hints in comments according to current DBMS
                 if (FALSE && $selectFields[0]['comments']) {
                     $output = $selectFields[0]['comments'] . ' ';
                 }
                 $output .= implode(', ', $outputParts);
             }
             break;
     }
     return $output;
 }