Welcome Guest, Not a member yet? Register   Sign In
database weirdness

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?

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.

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.


Theme © iAndrew 2016 - Forum software by © MyBB