From 9ee05e3f39e90ec7edfc68c41e18765c06daf0a1 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Thu, 30 Sep 2004 18:56:10 +0000 Subject: [PATCH] add db::setSchema() for specifying additional database namespaces. allows easy putting of external modules in separate logical namespaces. --- includes/DatabasePostgreSQL.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index f38b70c3da..d2b8599e04 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -60,6 +60,7 @@ class DatabasePgsql extends Database { $this->mUser = $user; $this->mPassword = $password; $this->mDBname = $dbName; + $this->mSchemas = array($wgDBschema,'public'); $success = false; @@ -75,9 +76,9 @@ class DatabasePgsql extends Database { wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" ); wfDebug( $this->lastError()."\n" ); } else { + $this->setSchema(); $this->mOpened = true; } - $this->query("SET search_path = $wgDBschema,public"); } return $this->mConn; } @@ -255,7 +256,7 @@ class DatabasePgsql extends Database { } function strencode( $s ) { - return pg_escape_string( $s ); + return addslashes( $s ); } /** @@ -432,6 +433,13 @@ class DatabasePgsql extends Database { $this->freeResult( $res ); return $version; } + + function setSchema($schema=false) { + $schemas=$this->mSchemas; + if ($schema) { array_unshift($schemas,$schema); } + $searchpath=$this->makeList($schemas,LIST_NAMES); + $this->query("SET search_path = $searchpath"); + } } /** -- 2.20.1