WAMP and SQLSRV: sqlsrv not included in `PDO::getAvailableDrivers()` after install

mOrloff picture mOrloff · Jul 8, 2013 · Viewed 7.1k times · Source

I've never been able to get SQL Server to play nicely in my WAMP environment, and I trying to finally solve it once and for all.

Tried:

  • Downloaded the latest SQL Server drivers from microsoft, then extracted and dropped them in my \wamp\bin\php\php5.4.3\ext dir.
  • I edited both the \wamp\bin\php\php5.4.3\php.ini and \wamp\bin\apache\apache2.4.2\bin\php.ini files to include extension=php_sqlsrv_54_ts.dll.
  • restarted all WAMP services
  • checked phpinfo ... no SQLSRV
  • checked PDO::getAvailableDrivers() ... got only Array( [0]=>mysql, [1]=>sqlite )

Now, I understand that PDO is included natively in PHP 5.3+, but since the MS instructions explicitly requires that extension=php_pdo.dll be enabled, so I figured I'd give that a shot too.

I downloaded the DLL from dlldll.com (1st encounter with that site, so I hoping it's a reputable source), extracted and moved the _php_pdo.dll_ file to my \wamp\bin\php\php5.4.3\ext dir, then added it into both the php.ini files ... no improvement.

As a side note, when I check the list of activated PHP ext's from the WAMPSERVER menu, the sqlserver extensions don't even show up on the list.

Just to test it out, I also tried uncommenting extension=php_pdo_pgsql.dll in the php.ini's, and that worked just fine ... "pgsql" was included in the avail drivers array.

My setup:

  • Wampserver 2.2 (64bit), running
    • Apache 2.4.2
    • PHP 5.4.3
  • Win 7 pro 64

What next?

I'm just about out of ideas.

The only thing I can think of is that maybe the SQLSRV drivers are 32bit, and not playing nicely with my 64bit setup ... ooohhh goodness .. I sure hope not.

Any tips/pointers are welcome ... especially if they don't include completely reinstalling ;)

Answer

J Higs picture J Higs · Oct 21, 2013

I was able to get the sqlsvr PHP PDO driver working on my slightly older version of WAMP 32-bit. Here is my setup:

  • WAMP 2.2 (32 bit)
    • Apache 2.2.21
    • PHP 5.3.8
  • Win 7 Pro 64 bit

Here is what I did:

  1. Downloaded the MS 3.0 drivers from here: http://www.microsoft.com/en-us/download/details.aspx?id=20098
  2. Unpacked all of the files into the PHP ext folder (C:\wamp\bin\php\php5.3.8\ext)
  3. Added this line to my apache php.ini file (C:\wamp\bin\apache\Apache2.2.21\bin\php.ini)

    extension=php_pdo_sqlsrv_53_ts.dll

  4. Downloaded and installed MS SQL Server 2012 Native Client ODBC driver from here: http://go.microsoft.com/fwlink/?LinkID=239648&clcid=0x409

After these steps my PHP code happily connected to my SQL Server database.