Beispiel #1
0
 /**
  * Render DISTINCT clause
  *
  * @param string   $sql SQL query
  * @return string|null
  */
 protected function _renderColumns($sql)
 {
     if (!count($this->_parts[self::COLUMNS])) {
         return null;
     }
     $columns = array();
     foreach ($this->_parts[self::COLUMNS] as $columnEntry) {
         list($correlationName, $column, $alias) = $columnEntry;
         if ($column instanceof JO_Db_Expr) {
             $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
         } else {
             if ($column == self::SQL_WILDCARD) {
                 $column = new JO_Db_Expr(self::SQL_WILDCARD);
                 $alias = null;
             }
             if (empty($correlationName)) {
                 $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
             } else {
                 $columns[] = $this->_adapter->quoteColumnAs(array($correlationName, $column), $alias, true);
             }
         }
     }
     return $sql .= ' ' . implode(', ', $columns);
 }