Welcome Guest, Not a member yet? Register   Sign In
Runtime database connection details setup
#1

[eluser]Unknown[/eluser]
Hello,
How can I access the database connect variables in one of my controllers? Something like /config/database.php, the reason for this is I must access multiple databases and don't know the connection details until runtime.
I could write a simple static php that reads the details, outputs in the /config/database.php and starts the CI application but that's really ugly coding, I'd like something like:
-no db autoconnect in config.
-controller1 reads the connection details: host, db, user, pass and stores in session
-controller2,3,4... reads from session and does something like:
$this->db->config->host= $this->db->config->user= etc and then $this->db->connect();

I don't know the number of DBs involved so multiple profiles in database.php is not an option.

Thank you!


Messages In This Thread
Runtime database connection details setup - by El Forum - 02-13-2010, 11:13 AM
Runtime database connection details setup - by El Forum - 02-13-2010, 07:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB