Etienne Noël
Etienne Noël

Reputation: 6166

Cannot find driver pdo_sqlsrv

I am using Symfony 3.0, PHP 5.6.17 on Windows 7, with IIS 7.5 and a SQL Server Database (MSSQL).

Like a lot of people, I'm currently having the pdo_exception:

  [Doctrine\DBAL\Exception\DriverException]
  An exception occured in driver: could not find driver



  [Doctrine\DBAL\Driver\PDOException]
  could not find driver



  [PDOException]
  could not find driver

However, I don't know how to trace the error. Here's what I have:

PHP.ini The two dll are properly named and located in the ext folder

;extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll

I tried activating and deactivating php_sqlsrv_56_nts.dll without any difference.

It looks, from phpinfo that the files are loaded:

enter image description here

Also, doing php -i I can see that it is enabled in command line also:

enter image description here

Finally, here's what I have in Symfony's config file:

doctrine:
    dbal:
        driver:   pdo_sqlsrv
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"

I really don't know what to look into anymore.

Upvotes: 1

Views: 6920

Answers (1)

miltone
miltone

Reputation: 4721

in this code you notice :

;extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll

You must decomment first line :

extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll

Also :

  • restart IIS
  • app/console doctrine:cache:clear-metadata
  • app/console doctrine:cache:clear-query
  • app/console doctrine:cache:clear-result
  • app/console cache:clear

Perhaps you can also read this : Topic StackOverflow for Doctrine MSSQL

Upvotes: 3

Related Questions