From c2697db0f2721cc9fefb58b85bf55e6bdb91db9b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 13:05:24 +0300 Subject: Rename a variable and style fixes in system/database/DB.php --- system/database/DB.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 116116bf4..96e495515 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -37,11 +37,11 @@ function &DB($params = '', $active_record_override = NULL) { // Load the DB config file if a DSN string wasn't passed - if (is_string($params) AND strpos($params, '://') === FALSE) + if (is_string($params) && strpos($params, '://') === FALSE) { // Is the config file in the environment folder? if (( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')) - AND ! file_exists($file_path = APPPATH.'config/database.php')) + && ! file_exists($file_path = APPPATH.'config/database.php')) { show_error('The configuration file database.php does not exist.'); } @@ -74,24 +74,24 @@ function &DB($params = '', $active_record_override = NULL) * parameter. DSNs must have this prototype: * $dsn = 'driver://username:password@hostname/database'; */ - if (($dns = @parse_url($params)) === FALSE) + if (($dsn = @parse_url($params)) === FALSE) { show_error('Invalid DB Connection String'); } $params = array( - 'dbdriver' => $dns['scheme'], - 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '', - 'port' => (isset($dns['port'])) ? rawurldecode($dns['port']) : '', - 'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '', - 'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '', - 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : '' + 'dbdriver' => $dsn['scheme'], + 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '', + 'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '', + 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '', + 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '', + 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : '' ); // were additional config items set? - if (isset($dns['query'])) + if (isset($dsn['query'])) { - parse_str($dns['query'], $extra); + parse_str($dsn['query'], $extra); foreach ($extra as $key => $val) { // booleans please @@ -158,4 +158,4 @@ function &DB($params = '', $active_record_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a8a2e3325c128ccdc941daba3bba10b78bf2d098 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Thu, 29 Mar 2012 03:56:46 +0700 Subject: Travis setup and minor cleanup --- system/database/DB.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 96e495515..e9434231c 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -138,7 +138,12 @@ function &DB($params = '', $active_record_override = NULL) class CI_DB extends CI_DB_driver { } } - require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php'); + // Load the DB driver + $driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php'; + + if ( ! file_exists($driver_file)) show_error('Invalid DB driver'); + + require_once($driver_file); // Instantiate the DB adapter $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; -- cgit v1.2.3-24-g4f1b From ee2f5d08c64d96b7abc7195bcd1b6a3fd67b5b42 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 30 Mar 2012 06:29:11 +0700 Subject: Multi database setup --- system/database/DB.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index e9434231c..0d81e40d3 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -92,16 +92,12 @@ function &DB($params = '', $active_record_override = NULL) if (isset($dsn['query'])) { parse_str($dsn['query'], $extra); + foreach ($extra as $key => $val) { - // booleans please - if (strtoupper($val) === 'TRUE') - { - $val = TRUE; - } - elseif (strtoupper($val) === 'FALSE') + if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL'))) { - $val = FALSE; + $val = var_export($val); } $params[$key] = $val; -- cgit v1.2.3-24-g4f1b