CodeIgniter Forums
dynamically setting dbprefix? - 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: dynamically setting dbprefix? (/showthread.php?tid=22277)



dynamically setting dbprefix? - El Forum - 09-03-2009

[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.


dynamically setting dbprefix? - El Forum - 09-24-2009

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


dynamically setting dbprefix? - El Forum - 09-24-2009

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

Enjoy
InsiteFX