You can always create your own class with a field variable with reference to the mysqli object and the 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);
source share