0

Does anyone know how to connect a Silex based Web Application to a MSSQL DB?

I tried the https://packagist.org/packages/localgod/pdo-service-provider

but don't know which driver I have to use.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
bambamboole
  • 577
  • 10
  • 30
  • As far as I understand your web server runs under unix? If fo you can use a PDO Sybase's driver which is compatible with MSSQL. I already make it ran with MSSQL2008R on a Redhat. – Fractaliste May 18 '15 at 08:25

1 Answers1

0

You shouldn't over think it, at the end you're just using PDO so check the PDO's manual and use the SQLSRVR driver.

NOTE: I've never used PDO in Ms SQL, but once installed the driver it should be straight forward to use, from the comments on the SQLSRV:

As of 12/12/2014, Microsoft has officially released Version 3.1.

Support for 5.5 has 4 drivers php_pdo_sqlsrv_55_nts.dll php_pdo_sqlsrv_55_ts.dll php_sqlsrv_55_nts.dll php_sqlsrv_55_ts.dll

Note: Version 3.1 now supports PHP 5.5 and requires Microsoft ODBC Driver 11 (or higher)

You can downlod the new driver from http://www.microsoft.com/en-us/download/details.aspx?id=20098

So, once enabled you can just use the sqlsrv and this should work (or you can skip this provider and use raw PDO: $c = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password");)

Edited to give Linux/Unix instructions:

If you are running your PHP code from linux, you just need to use de default ODBC driver (from the docs: The PDO_SQLSRV extension is only compatible with PHP running on Windows. For Linux, see ODBC and » Microsoft's SQL Server ODBC Driver for Linux.)

Also take a look at this answer.

Community
  • 1
  • 1
mTorres
  • 3,590
  • 2
  • 25
  • 36