From: OverlordQ Date: Fri, 29 Apr 2011 22:27:34 +0000 (+0000) Subject: Followup to r85907, correctly quote table names. X-Git-Tag: 1.31.0-rc.0~30505 X-Git-Url: http://git.cyclocoop.org/%22%22._DIR_PLUGIN_FULLCALENDAR.%22prive/themes/spip/images/event_edit.png/Special:BookSources/1235467890?a=commitdiff_plain;h=245e6b067ae48198869a1498fb3f5d9fa93000b3;p=lhc%2Fweb%2Fwiklou.git Followup to r85907, correctly quote table names. Followup to r87129, add handling of arrayed GROUP BY/ORDER BY options to match core class so that this will indeed work. --- diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 521e8c00a8..446fd802d6 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -39,7 +39,7 @@ AND relname=%s AND attname=%s; SQL; - $table = $db->tableName( $table ); + $table = $db->tableName( $table, false ); $res = $db->query( sprintf( $q, $db->addQuotes( $wgDBmwschema ), @@ -819,7 +819,7 @@ class DatabasePostgres extends DatabaseBase { if ( !$schema ) { $schema = $wgDBmwschema; } - $table = $this->tableName( $table ); + $table = $this->tableName( $table, false ); $etable = $this->addQuotes( $table ); $eschema = $this->addQuotes( $schema ); $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " @@ -1002,13 +1002,21 @@ SQL; } 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'] ) ) { $preLimitTail .= " HAVING {$options['HAVING']}"; } + 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'] ) ) {