Reputation: 1606
I have a link to a db resource, but in some cases i get a mysql link and in some other cases the functions get a postgresql resource type.
Depending on the connection type, I need to do different things. How can I test the type of the connection?
In some cases I need to use $res = pg_query($link, $sqlcmd)
and in some other cases I need to use something like mysql_query
.
Any suggestions?
I tried already get_class
and get_type
.
Upvotes: 1
Views: 150
Reputation: 17009
You may want to look at get_resource_type()
. It returns the resource type.
For example:
$res = mysql_query($query);
if(get_resource_type($res) == 'mysql result') {
// mysql result
} elseif(get_resource_type($res) == 'pgsql result') {
// pgsql result
}
Upvotes: 3