CodeIgniter Forums

Full Version: dynamically setting dbprefix?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
I have an application where I need to have the dbprefix set dynamically when a user logs in. My thought was that I could set the dbprefix value to the user session and the queries in the models would simply read the session. My problem is that I'm not sure how to dynamically set the dbprefix on the fly. Is there a call I can make to set the current config to change the dbprefix value? I imagine that I could just set a variable to use in the statements, but it seems like a better idea to maintain the coding standard of using the dbprefix feature that ci has.

El Forum

[eluser]imn.codeartist[/eluser]
try this
$this->db->dbprefix='your prefix';

El Forum

[eluser]InsiteFX[/eluser]
Read the users guide!

Enjoy
InsiteFX