CodeIgniter Forums
database name available within models - 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 name available within models (/showthread.php?tid=33829)



database name available within models - El Forum - 09-09-2010

[eluser]alive[/eluser]
Is there a way to have access to the current database name (set up in database.php) in a model? I can always load the database config file, but it seems like so obvious a need that there's probably already an easier way I'm not aware of. Something like a
Code:
$this->db->name
variable or a function tucked neatly away in the database class.

Any help to offer?


database name available within models - El Forum - 09-09-2010

[eluser]danmontgomery[/eluser]
Code:
$this->db->database



database name available within models - El Forum - 09-09-2010

[eluser]alive[/eluser]
Works like a charm. Thanks. Is that in the User Guide? If not, where does one find little treats like that?


database name available within models - El Forum - 09-09-2010

[eluser]danmontgomery[/eluser]
Not in the documentation anywhere I've seen... I just searched system/database for mysql_select_db.