PDO MSSQL Server - Driver not found

后端 未结 3 1615
感情败类
感情败类 2020-12-06 14:23

I am currently trying to connect to my localdb on MSSQL 2012 Express.

I have downloaded and installed the official microsoft driver from http://www.microsoft.com/en-

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 14:44

    Another possibility is to use the odbc drivers which are by default included in the php extensions, you still might have to uncomment them in your php.ini though.

    extension=php_pdo_odbc.dll
    

    Don't forget to restart your server afterwards ;-)

    And then use it like this:

    $db = new PDO('odbc:Driver={SQL Server};Server=192.168.x.x;Database=DatabaseName; Uid=User;Pwd=Password');
    $stmt = $db->query("SELECT the_usual FROM aTable WHERE all='well'");
    

提交回复
热议问题