PDO Installation

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

PDO Installation

Post by Ree »

I have a problem installing PDO drivers for PHP 5.1.4 on Windows XP. I have followed the instructions here and added the following in my php.ini:

Code: Select all

extension=php_pdo.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
PHP seems to find the PDO extension itself, but not the drivers. Under PDO section PDO Drivers has no value and obviously when trying to use PDO in code I get the 'could not find driver' exception:

Code: Select all

try
{
  $db = new PDO('mysql:host=localhost;dbname=circus_arts_db', 'user', 'pass');
} catch (Exception $e)
{
  echo $e->getMessage();
}
Any clues why this is happening? I double checked the dlls and they are available in the extension directory.

Solution: For MySQL and MS SQL to be available with PDO you need to copy libmysql.dll and ntwdblib.dll into your <windows root>\system32\ directory. Actually, I'm surprised this is not documented on PDO page.
Last edited by Ree on Mon Jun 19, 2006 1:54 am, edited 1 time in total.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Code: Select all

<?php
print_r(PDO::getAvailableDrivers());
?>
What is this returning?
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

An empty array of course.
Post Reply