Hi all,
I want to use extension_loaded() to check my users' choice of DB server before I try and initiate a connection with ADODB. I am providing the following options for DB server:
mssql
mysql
oracle 8/9
postgres
I'd like to know the string for each of these to pass to the function (I'm guessing 'mysql' is correct, but for the others? I'm a bit concerned about the case-sensitivity of the function too), and also if this is a 100% solid check that the extension is loaded and supported by the PHP installation.
Thanks
Help with extension_loaded() please
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
- Load the extensions
- use get_loaded_extensions() to get an array of the extensions you have loaded and find them in it.
- strtolower() or strtoupper() may be of interest, as may strcasecmp().
Thanks feyd.
Is this good enough do you think?
All I really need to know is the strings to pass to the function - are the 4 I have chosen all that will ever be used, or are the extensions referred to by other names?
Is this good enough do you think?
Code: Select all
switch($conf['db_type'])
{
case 'mssql':
if (!extension_loaded('mssql')) return 'This installation of PHP has not loaded the MS SQL Server extension.';
break;
case 'mysql':
if (!extension_loaded('mysql')) return 'This installation of PHP has not loaded the MySQL extension.';
break;
case 'oci8':
if (!extension_loaded('oci8')) return 'This installation of PHP has not loaded the Oracle extension.';
break;
case 'postgres7':
if (!extension_loaded('pgsql')) return 'This installation of PHP has not loaded the PostgreSQL extension.';
break;
default:
return sprintf('[%s] is not a supported database type.', $conf['db_type']);
break;
}