SQL Server PHP PDO exception: could not find driver

0

I am trying to connect to a database in SQL Server 2008 from Yii2. My version of php is 5.6.31

This is my configuration file in db.php

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mssql:host=127.0.0.1;dbname=softwareoperacional',
    'username' => 'sa',
    'password' => 'admin123',
    'charset' => 'utf8',
];

I receive the following error message:

  

exception 'PDOException' with message 'could not find driver' in   C: \ xampp \ htdocs \ basic \ vendor \ yiisoft \ yii2 \ db \ Connection.php: 646

Additional information

  • Yii vesion 2.0.12
  • PHP version 5.6.31
  • Operating system Windows 7 sp1
asked by Sebastian Salazar 01.03.2018 в 07:15
source

1 answer

1

Your server does not have any driver enabled to connect to SQL Server. According to the version of your PHP, you should install the SQLSRV driver provided by Microsoft ( instructions in the Microsoft documentation ) and enable it in php_ini by adding the line:

extension=php_pdo_sqlsrv_54_ts.dll

(This line must point to the corresponding dll) and then restart Apache.

This other page contains detailed instructions to enable the SQL Server driver in XAMPP.

    
answered by 01.03.2018 в 13:14