I have a generic function that closes connections and it takes a dbh, the currently open database handle by ref.
I call it like this
closeconnection($dbh)
depending on the case whether this dbh was a sqlsrv dbh or a mysql dbh, I do one of the two things;
sqlsrv_close( $dbh);
or
mysql_close($dbh);
Short of passing the connection type in the function call, is there a way to find out whether this is a mysql or mssql handle programmatically by simply probing the $dbh which was passed by ref?
Try using
get_resource_type($dbh);. It’ll returnmysql linkfor a MySQL DB handle. I don’t know what it will return for anything else as MySQL is all I have handy.