I have a global variable for a mysqli connection set like so:
$mysqli = new mysqli($dbserver, $dbuser, $dbpass, $dbname);
The php manual says:
Open non-persistent MySQL connections and result sets are automatically closed when their objects are destroyed.
If I reassign the variable to a new connection (using the same code) is this the same as destroying the object? Or do I need to destroy the variable explicitly?
I know I can use $mysqli->close(); but prefer to avoid possible error conditions.
If I do need to destroy the object, is there a simple test to make sure the connection is a valid one first (e.g. using isset)?