From a659728096e1d963b0672d7ab53a622388f58978 Mon Sep 17 00:00:00 2001 From: Platonides Date: Tue, 12 Apr 2011 17:00:08 +0000 Subject: [PATCH] Add parameter to tableName() to get the bare table name. --- includes/db/Database.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 19a125c8ad..7bb13dfba7 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1513,9 +1513,11 @@ abstract class DatabaseBase implements DatabaseType { * when calling query() directly. * * @param $name String: database table name + * @param $quoted Boolean: Automatically pass the table name through + * addIdentifierQuotes() so that it can be used in a query. * @return String: full database name */ - function tableName( $name ) { + function tableName( $name, $quoted = true ) { global $wgSharedDB, $wgSharedPrefix, $wgSharedTables; # Skip the entire process when we have a string quoted on both ends. # Note that we check the end so that we will still quote any use of @@ -1561,10 +1563,10 @@ abstract class DatabaseBase implements DatabaseType { # Quote the $database and $table and apply the prefix if not quoted. if ( isset( $database ) ) { - $database = ( $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) ); + $database = ( !$quoted || $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) ); $prefix = ''; } - $table = ( $this->isQuotedIdentifier( $table ) ? $table : $this->addIdentifierQuotes( "{$prefix}{$table}" ) ); + $table = ( !$quoted || $this->isQuotedIdentifier( $table ) ? $table : $this->addIdentifierQuotes( "{$prefix}{$table}" ) ); # Merge our database and table into our final table name. $tableName = ( isset( $database ) ? "{$database}.{$table}" : "{$table}" ); -- 2.20.1