Ejemplo n.º 1
0
 /**
  * Render FROM clause with using of addotional specifications for index usage
  *
  * @param string   $sql SQL query
  * @return string
  */
 protected function _renderFrom($sql)
 {
     $sql = parent::_renderFrom($sql);
     // Add index definitions for MySQL optimizer
     $replace = array();
     foreach ($this->_parts[self::FROM] as $correlationName => $table) {
         if (!isset($this->_parts[self::INDEX][$correlationName]) || !isset($this->_indexSqlTypes[$this->_parts[self::INDEX][$correlationName]['type']])) {
             continue;
         }
         $indexInstruction = $this->_parts[self::INDEX][$correlationName];
         $replace['from'][] = $this->_getQuotedTable($table['tableName'], $correlationName);
         $replace['to'][] = $this->_getQuotedTable($table['tableName'], $correlationName) . ' ' . sprintf($this->_indexSqlTypes[$indexInstruction['type']], implode(',', array_map(array($this->_adapter, 'quoteIdentifier'), $indexInstruction['indexes'])));
     }
     if ($replace) {
         $sql = str_replace($replace['from'], $replace['to'], $sql);
     }
     return $sql;
 }