From 8e16cc0c1921b2e4e9bdedbe44d4cf9754b54613 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 11 Feb 2014 14:38:08 -0500 Subject: [PATCH] Fix dsn issue in tests --- drivers/mysql/mysql_driver.php | 4 +++- drivers/pgsql/pgsql_driver.php | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mysql/mysql_driver.php b/drivers/mysql/mysql_driver.php index 7dd3ab1..01bf027 100644 --- a/drivers/mysql/mysql_driver.php +++ b/drivers/mysql/mysql_driver.php @@ -38,7 +38,7 @@ class MySQL extends DB_PDO { */ public function __construct($dsn, $username=null, $password=null, $options=array()) { - // Automatically set the charset to UTF-8 + // Set the charset to UTF-8 if (defined('PDO::MYSQL_ATTR_INIT_COMMAND')) { $options = array_merge($options, array( @@ -46,6 +46,8 @@ class MySQL extends DB_PDO { )); } + if (strpos($dsn, 'mysql') === FALSE) $dsn = 'mysql:'.$dsn; + parent::__construct($dsn, $username, $password, $options); } diff --git a/drivers/pgsql/pgsql_driver.php b/drivers/pgsql/pgsql_driver.php index c7fa5d2..0e453dd 100644 --- a/drivers/pgsql/pgsql_driver.php +++ b/drivers/pgsql/pgsql_driver.php @@ -31,6 +31,8 @@ class PgSQL extends DB_PDO { */ public function __construct($dsn, $username=null, $password=null, $options=array()) { + if (strpos($dsn, 'pgsql') === FALSE) $dsn = 'pgsql:'.$dsn; + parent::__construct($dsn, $username, $password, $options); }