Changeset 2487

Show
Ignore:
Timestamp:
08/05/2008 08:03:05 PM (4 months ago)
Author:
knut
Message:

fixed #834

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/HISTORY

    r2486 r2487  
    11Version 3.1.3 To Be Released 
    22============================ 
     3BUG: Ticket#834 - TDbCommandBuilder::applyOrdering(): Add support for function calls in ORDER BY clause (Knut) 
    34BUG: Ticket#836 - TRatingList downgrade (Christophe) 
    45BUG: Ticket#841 - Strange output from THttpResponse (Christophe) 
  • trunk/framework/Data/Common/TDbCommandBuilder.php

    r2482 r2487  
    106106        { 
    107107                $orders=array(); 
    108                 foreach($ordering as $name=>$direction) 
     108                foreach($ordering as $name => $direction) 
    109109                { 
    110110                        $direction = strtolower($direction) == 'desc' ? 'DESC' : 'ASC'; 
    111                         $column = $this->getTableInfo()->getColumn($name)->getColumnName(); 
    112                         $orders[] = $column.' '.$direction; 
     111                        if(strpos($name, '(') && strpos($name, ')')) { 
     112                                // key is a function (bad practice, but we need to handle it) 
     113                                $key = $name; 
     114                        } else { 
     115                                // key is a column 
     116                                $key = $this->getTableInfo()->getColumn($name)->getColumnName(); 
     117                        } 
     118                        $orders[] = $key.' '.$direction; 
    113119                } 
    114120                if(count($orders) > 0)