MSSQL PDO could not find driver

后端 未结 2 672
醉酒成梦
醉酒成梦 2020-12-16 19:22

I\'m using PHP Version 5.3.8 that was installed via XAMPP along with Microsoft SQL Server 2008 R2 (SQLEXPRESS). I have the drivers installed correctly (i guess) and have add

相关标签:
2条回答
  • 2020-12-16 19:58

    Not sure if this is due to running a CentOS x86_64 machine but sqlsrv didn't work as the driver for me, I had to use dblib:

    try {
    
        $DBH = new PDO("dblib:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');
    
    } catch (PDOException $e) {
    
        echo $e->getMessage();
    }
    

    Source and thanks to.

    0 讨论(0)
  • 2020-12-16 20:01

    mssql is the old way of doing it, sqlsrv should be more appropriate! In fact the extension is called (extension=php_pdo_sqlsrv_53_ts_vc9.dll) as well ;)

    try {
    
        $DBH = new PDO("sqlsrv:Server=xxxx;Database=xxxx", 'xxxx', 'xxxx');
    
    } catch (PDOException $e) {
    
        echo $e->getMessage();
    }
    

    Hope this helps!

    Source : http://php.net/manual/fr/ref.pdo-sqlsrv.connection.php

    0 讨论(0)
提交回复
热议问题