CodeIgniter Forums
CI 1.6.1, Database Class, Manually Connecting, Passing an array of values - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI 1.6.1, Database Class, Manually Connecting, Passing an array of values (/showthread.php?tid=6427)



CI 1.6.1, Database Class, Manually Connecting, Passing an array of values - El Forum - 02-26-2008

[eluser]Unknown[/eluser]
Hi everyone.

I was trying to connect manually to a database by passing an array of values, with the database configuration.

Example:

Code:
$config['hostname'] = "//solap/oracle";
$config['username'] = "environmentdw";
$config['password'] = "password";
$config['database'] = "oracle";
$config['dbdriver'] = "oci8";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['active_r'] = FALSE;

$this->load->database($config);

This kept me showing the following error: You have not selected a database type to connect to.

I digged into the system/database/DB.php file and realized that the load->database($config) was being interpreted as a DSN string.

I solved this issue by adding the following line
Code:
if(!is_array($params))
before line 28
Code:
if (is_string($params) AND strpos($params, '://') === FALSE)

I don't know if it's a bug.
Keep up the good work.


CI 1.6.1, Database Class, Manually Connecting, Passing an array of values - El Forum - 02-26-2008

[eluser]Derek Jones[/eluser]
Thanks Zebra, this has been recently fixed in the svn.