CodeIgniter Forums
database weirdness - 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: database weirdness (/showthread.php?tid=21647)



database weirdness - El Forum - 08-16-2009

[eluser]DougW[/eluser]
I have my default database set up in database.php in config. I want a user to log in using a user table in that default database and THEN load that users's parameters for his own database to connect to. I can;t add the database connection parms in database.php because when that gets loaded I don't know them yet.

Can I set those parms to dummy variables, then reset them after I load the user's data and THEN connect to the DB in my model?

Is there a better way?


database weirdness - El Forum - 08-17-2009

[eluser]tomcode[/eluser]
You can solve this by connecting to multiple databases, see Connecting to your Database, , section Manually Connecting to a Database and section Connecting to Multiple Databases.


database weirdness - El Forum - 08-17-2009

[eluser]DougW[/eluser]
That doesn't actually work because the variables that I want to use for database host, name user and password don't exist yet. So when the class is instantiated I get warnings. I got around it by defining variables in index, then reassigning them after the user logged in THEn calling for a manual connection in the constructor of the model.

Thanks!