CodeIgniter Forums
Get current database name - 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: Get current database name (/showthread.php?tid=27264)



Get current database name - El Forum - 02-05-2010

[eluser]Gaz[/eluser]
Hi all,

Is there a function (or code snippet) to return the currently active database name?

I know I can use mysql_db_name, but where do I get the connection ID from?

Cheers,
Gaz.


Get current database name - El Forum - 02-05-2010

[eluser]danmontgomery[/eluser]
You don't pass mysql_db_name a connection ID.

http://php.net/manual/en/function.mysql-db-name.php
http://www.php.net/manual/en/function.mysql-list-dbs.php

However,

Code:
echo $this->db->database;



Get current database name - El Forum - 02-05-2010

[eluser]Gaz[/eluser]
OK, thanks on both counts :-)

Cheers,
Gaz.