CodeIgniter Forums
database name available within models - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: database name available within models (/thread-33829.html)



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.