From 10aa275e6b1eac38934581acd9eb6a0f25e2f310 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Mon, 31 Jan 2011 21:04:40 +0000 Subject: [PATCH] fix Bug#26274: Database layer should allow arrays for ORDER BY, GROUP BY --- includes/db/Database.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 1a046397ca..5adf5dac5e 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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'])) { -- 2.20.1