First thing that comes to mind, is a container class, that stores MySQLi object in it.
Something like this:
class MySQLiContainer extends SplObjectStorage{
public function newConnection($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null) {
$mysqli = new mysqli($host, $username, $passwd, $dbname, $port, $socket);
$this->attach($mysqli);
return $mysqli;
}
}
//usage
$mysqliContainer = new MySQLiContainer();
$c1 = $mysqliContainer->newConnection('localhost','root','root','localDatabase');
$c1->query('SELECT ....');
$c2 = $mysqliContainer->newConnection('mysql.remotehost.net','hackermom','bobbytables','schoolDatabase');
$name = 'Robert\'); DROP TABLE students;--';
$c2->multi_query("SELECT * FROM students WHERE name = '$name'");
Without knowing more about functionality required, it's hard to say if this is a good idea though ;)
More info about SplObjectStorage class.