mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merged revisions 50179 via svnmerge from
http://svn.silverstripe.com/open/modules/sapphire/branches/2.2.2 ........ r50179 | sminnee | 2008-02-26 12:03:10 +1300 (Tue, 26 Feb 2008) | 2 lines Fixed 4.1-sort-by-group-aggregate query rewriter for sort functions containing columns, eg, ORDER BY if(A,B,C), X ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@50862 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9392c0fdb2
commit
ecec061408
@ -1387,7 +1387,19 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
if($sort && strpos($sort,'(') !== false) {
|
||||
// Sort can be "Col1 DESC|ASC, Col2 DESC|ASC", we need to handle that
|
||||
$sortParts = explode(",", $sort);
|
||||
foreach($sortParts as $i => $sortPart) {
|
||||
|
||||
// If you have select if(X,A,B),C then the array will return 'if(X','A','B)','C'.
|
||||
// Turn this into 'if(X,A,B)','C' by counting brackets
|
||||
while(list($i,$sortPart) = each($sortParts)) {
|
||||
while(substr_count($sortPart,'(') > substr_count($sortPart,')')) {
|
||||
list($i,$nextSortPart) = each($sortParts);
|
||||
if($i === null) break;
|
||||
$sortPart .= ',' . $nextSortPart;
|
||||
}
|
||||
$lumpedSortParts[] = $sortPart;
|
||||
}
|
||||
|
||||
foreach($lumpedSortParts as $i => $sortPart) {
|
||||
$sortPart = trim($sortPart);
|
||||
if(substr(strtolower($sortPart),-5) == ' desc') {
|
||||
$select[] = substr($sortPart,0,-5) . " AS _SortColumn{$i}";
|
||||
|
Loading…
Reference in New Issue
Block a user