Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php: getting database name from own mysli class

i made a wrapper class for mysqli with the following syntax:

class mydb extends mysqli
{
     ....
}

i'm creating instances like the following:

$conn = new mydb($host $username , $pass, $dbname);

i'm wondering - how can i access $dbname from inside the class? i'm looking for an mysqli equivalent for the mysql_db_name() function.

like image 852
Fuxi Avatar asked Aug 24 '13 00:08

Fuxi


1 Answers

You can use this SQL query from your own class:

SELECT database() AS the_db

That should show you the current DB you have selected.

like image 108
Aaron Gong Avatar answered Oct 03 '22 19:10

Aaron Gong