Working with PDO extensions on IIS

Categories:

Have you ever tried enabling the php_pdo_mysql.dll extension or similar only to find that PHP reports that it is unable to load it or even have PHP crash? This is probably because you followed the normal process for enabling PHP extensions for Windows. If you did this with your PDO extensions however, you'd be wrong.

With the exception of a quirk or two, enabling your PHP extensions is as simple as removing the semi colon from in front of the extension you want to load in php.ini and then recycling your application pool (or restarting IIS if using IIS 5.x).

Although you can compile your own PHP binaries with PDO loaded, by default the binaries from PHP.net come with PDO configured as a shared library which simplifies the upgrade path. As a shared library you first need to enable the PDO php_pdo.dll extension in php.ini, and then load any specific database drivers such as php_pdo_mssql.dll, php_pdo_mysql.dll or php_pdo_odbc.dll. For example the extensions section of your php.ini would have your PDO configuration look something like this;

extension=php_pdo.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_informix.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll 

Once you've done this you can save your php.ini file, and recycle your application pool to apply the changes. To test your PDO extensions are loading use the phpinfo function.

Hopefully you now have you PDO extensions up and running. As always, please post support requests in the forums, otherwise feel free to post comments and feedback below.

Average rating
(3 votes)