php: getting database name from own mysli class -


i made wrapper class mysqli following syntax:

class mydb extends mysqli {      .... } 

i'm creating instances following:

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

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

you make own class has field variable reference mysqli object , database name.

class mydatabase {      public $dbi;     public $dbname;      function __construct($host, $user, $pass, $db) {         $this->dbi = new mysqli($host, $user, $pass, $db);         $this->dbname = $db;     }  }  $mydb = new mydatabase($host, $user, $pass, $db);  //access db name stored during connection echo $mydb->dbname; 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -