From 54f4cb2644e0ffe59d3fe936220282940dc31087 Mon Sep 17 00:00:00 2001 From: Rack Lin Date: Thu, 19 Jul 2012 12:55:23 +0800 Subject: [PATCH] Added support PostgreSQL schema setting, if schema has been specified. Signed-off-by: Rack Lin --- application/config/database.php | 1 + laravel/database/connectors/postgres.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/application/config/database.php b/application/config/database.php index d5e6ac1b..021bcce9 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -85,6 +85,7 @@ 'password' => '', 'charset' => 'utf8', 'prefix' => '', + 'schema' => 'public', ), 'sqlsrv' => array( diff --git a/laravel/database/connectors/postgres.php b/laravel/database/connectors/postgres.php index 3721f368..d4a54344 100644 --- a/laravel/database/connectors/postgres.php +++ b/laravel/database/connectors/postgres.php @@ -44,6 +44,13 @@ public function connect($config) $connection->prepare("SET NAMES '{$config['charset']}'")->execute(); } + // If a schema has been specified, we'll execute a query against + // the database to set the search path. + if (isset($config['schema'])) + { + $connection->prepare("SET search_path TO '{$config['schema']}'")->execute(); + } + return $connection; }