I have a base model class that wraps mysqli. When I instantiate multiple models each one calls new mysqli(). If the parameters passed to mysqli() are the same will it be optimized for me and only use one connection?
I guess another way to ask this is...is this:
$mysqli1 = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
$mysqli2 = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
$mysqli3 = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
more or less equivalent to this:
$mysqli1 = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
$mysqli2 = $mysqli1;
$mysqli3 = $mysqli1;
Edit: I remember reading somewhere that it does return a copy if you're already connected but I can't find it now.
var_dump($mysqli1); var_dump($mysqli2); ...You'll see a different object reference # for each one. (they won't be optimized down, you'll get a pile of different connection resources)