diff options
author | Derek Jones <derek.jones@ellislab.com> | 2008-05-14 17:01:50 +0200 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2008-05-14 17:01:50 +0200 |
commit | 97bc010749830b183fffa7c5faf29744c095864e (patch) | |
tree | c98b36a2199963ca720e2d6c819febde90edbc0f | |
parent | 454fa7e0039689ca480eb6ef999d3fa753f5f875 (diff) |
fixed bug #3419 where the 'database' setting for DSN connections was using the host portion of the URL instead of the path.
Added ability to set other db config values in DSN connections via query string
-rw-r--r-- | system/database/DB.php | 25 | ||||
-rw-r--r-- | system/database/DB_driver.php | 2 | ||||
-rw-r--r-- | user_guide/changelog.html | 13 | ||||
-rw-r--r-- | user_guide/database/connecting.html | 5 |
4 files changed, 42 insertions, 3 deletions
diff --git a/system/database/DB.php b/system/database/DB.php index 2446645a7..eb25273a1 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -66,10 +66,31 @@ function &DB($params = '', $active_record_override = FALSE) 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',
'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',
'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',
- 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['host'], 1)) : ''
+ 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''
);
+
+ // were additional config items set?
+ if (isset($dns['query']))
+ {
+ parse_str($dns['query'], $extra);
+
+ foreach($extra as $key => $val)
+ {
+ // booleans please
+ if (strtoupper($val) == "TRUE")
+ {
+ $val = TRUE;
+ }
+ elseif (strtoupper($val) == "FALSE")
+ {
+ $val = FALSE;
+ }
+
+ $params[$key] = $val;
+ }
+ }
}
-
+
// No DB specified yet? Beat them senseless...
if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '')
{
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a0833d0ce..c9cece621 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -36,6 +36,8 @@ class CI_DB_driver { var $database;
var $dbdriver = 'mysql';
var $dbprefix = '';
+ var $char_set = '';
+ var $dbcollat = '';
var $autoinit = TRUE; // Whether to automatically initialize the DB
var $swap_pre = '';
var $port = '';
diff --git a/user_guide/changelog.html b/user_guide/changelog.html index de1818cb9..0d7265e89 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -60,8 +60,21 @@ Change Log <h2>Version 1.6.3</h2>
<p>Release Date: not currently released<br />
SVN Revision: not currently released</p>
+<ul>
+ <li>Database
+ <ul>
+ <li>Added ability to set additional database config values in <a href="database/connecting.html">DSN connections</a> via the query string.</li>
+ </ul>
+ </li>
+</ul>
+<h3>Bug fixes for 1.6.3</h3>
+
+<ul>
+ <li>Amended fixes for bug (#3419) with parsing DSN database connections.</li>
+</ul>
+
<h2>Version 1.6.2</h2>
<p>Release Date: May 13, 2008<br />
SVN Revision: 1155</p>
diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index ee2d8c08f..bc4b2e7e7 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -117,8 +117,11 @@ $this->load->database(<samp>$config</samp>);</code> <br />
$this->load->database(<samp>$dsn</samp>);</code>
-<p>Note that if you use a DSN you will not be able to specify some of the default values like you can if you use a connection array.</p>
+<p>To override default config values when connecting with a DSN string, add the config variables as a query string.</p>
+<code>$dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=/path/to/cache';<br />
+<br />
+$this->load->database(<samp>$dsn</samp>);</code>
<h2>Connecting to Multiple Databases</h2>
|