/**
  * Compiles a CASE ... WHEN flow-control construct based on input array (made with ->parseCaseStatement())
  *
  * @param	array		Array of case components, (made with ->parseCaseStatement())
  * @param	boolean		Whether function mapping should take place
  * @return	string		case when string
  * @see parseCaseStatement()
  */
 protected function compileCaseStatement(array $components, $functionMapping = TRUE)
 {
     switch ((string) $GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type']) {
         case 'native':
             $output = parent::compileCaseStatement($components);
             break;
         case 'adodb':
             $statement = 'CASE';
             if (isset($components['case_field'])) {
                 $statement .= ' ' . $components['case_field'];
             } elseif (isset($components['case_value'])) {
                 $statement .= ' ' . $components['case_value'][1] . $components['case_value'][0] . $components['case_value'][1];
             }
             foreach ($components['when'] as $when) {
                 $statement .= ' WHEN ';
                 $statement .= $this->compileWhereClause($when['when_value'], $functionMapping);
                 $statement .= ' THEN ';
                 $statement .= $when['then_value'][1] . $when['then_value'][0] . $when['then_value'][1];
             }
             if (isset($components['else'])) {
                 $statement .= ' ELSE ';
                 $statement .= $components['else'][1] . $components['else'][0] . $components['else'][1];
             }
             $statement .= ' END';
             $output = $statement;
             break;
     }
     return $output;
 }