From: Greg Sabino Mullane Date: Tue, 2 Jan 2007 21:34:42 +0000 (+0000) Subject: Add implicitGroupby function to account for different database behaviors. X-Git-Tag: 1.31.0-rc.0~54692 X-Git-Url: http://git.cyclocoop.org/%22.%24match%5B1%5D.%22?a=commitdiff_plain;h=765ed250697b52e5c0fdc78bbe5532271d66c255;p=lhc%2Fweb%2Fwiklou.git Add implicitGroupby function to account for different database behaviors. --- diff --git a/includes/Database.php b/includes/Database.php index 14764bd8fd..eb1ee1359c 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -369,6 +369,13 @@ class Database { return false; } + /** + * Returns true if this database does an implicit sort when doing GROUP BY + */ + function implicitGroupby() { + return true; + } + /**#@+ * Get function */ diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index b78e6d5c51..803c0e26fb 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -37,6 +37,10 @@ class DatabasePostgres extends Database { return true; } + function implicitGroupby() { + return false; + } + static function newFromParams( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0) { diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php index 89cff20a05..346eac633d 100644 --- a/includes/SpecialCategories.php +++ b/includes/SpecialCategories.php @@ -30,10 +30,11 @@ class CategoriesPage extends QueryPage { $NScat = NS_CATEGORY; $dbr =& wfGetDB( DB_SLAVE ); $categorylinks = $dbr->tableName( 'categorylinks' ); + $implicit_groupby = $dbr->implicitGroupby() ? '1' : 'cl_to'; $s= "SELECT 'Categories' as type, {$NScat} as namespace, cl_to as title, - 1 as value, + $implicit_groupby as value, COUNT(*) as count FROM $categorylinks GROUP BY 1,2,3,4";