Search code examples
phpdatabaseconnectionresource-id

Is there a way to tell the differences of a PostgreSQL, MySQL or MSSQL connection resource?


If I have $dbConn (a database connection) and I don't know if it's MySQL, MSSQL or PostgreSQL can I tell what type of connection it is?

Just wanted to know if there is a method to return the connection type of a resource id?

EDIT: Sorry, yes PHP added the tag


Solution

  • $connection = mysql_connect(...); 
    
    $is_mysql = (get_resource_type($connection) == 'mysql link');
    $is_ibase = (get_resource_type($connection) == 'Firebird/InterBase link'); // *
    
    var_dump($is_mysql); // -> true
    
    // * supposed to be "interbase link" but isn't any longer