fix Bug#26274: Database layer should allow arrays for ORDER BY, GROUP BY
authorMark A. Hershberger <mah@users.mediawiki.org>
Mon, 31 Jan 2011 21:04:40 +0000 (21:04 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Mon, 31 Jan 2011 21:04:40 +0000 (21:04 +0000)
includes/db/Database.php

index 1a04639..5adf5da 100644 (file)
@@ -950,7 +950,10 @@ abstract class DatabaseBase implements DatabaseType {
                }
 
                if ( isset( $options['GROUP BY'] ) ) {
-                       $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
+                       $gb = is_array( $options['GROUP BY'] )
+                               ? implode( ',', $options['GROUP BY'] )
+                               : $options['GROUP BY'];
+                       $preLimitTail .= " GROUP BY {$gb}";
                }
 
                if ( isset( $options['HAVING'] ) ) {
@@ -958,7 +961,10 @@ abstract class DatabaseBase implements DatabaseType {
                }
 
                if ( isset( $options['ORDER BY'] ) ) {
-                       $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
+                       $ob = is_array( $options['ORDER BY'] )
+                               ? implode( ',', $options['ORDER BY'] )
+                               : $options['ORDER BY'];
+                       $preLimitTail .= " ORDER BY {$ob}";
                }
 
                // if (isset($options['LIMIT'])) {