1

I tried to change mysql to ms sql server dbms in yii but encounter PDO Exception, "Caused by: PDOException could not find driver". What is the issue there?

This is db.php file.

'class' => 'yii\db\Connection',
'dsn' => 'sqlsrv:Server=localhost;Database=mydb',
'username' => 'myusername',
'password' => 'myps',
'charset' => 'utf8'

This is config.php.

'components' => [
    'db' => [
        'dsn' => 'sqlsrv:Server=localhost;Database=mydb',
    ],
miken32
  • 42,008
  • 16
  • 111
  • 154
JohnnyCc
  • 525
  • 1
  • 8
  • 23
  • Possible duplicate of [PDOException “could not find driver”](https://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver) – miken32 Sep 19 '17 at 21:56

1 Answers1

3

You need to install PDO driver for your database type.

Before proceeding, make sure you have installed both the PDO PHP extension and the PDO driver for the database you are using (e.g. pdo_mysql for MySQL). This is a basic requirement if your application uses a relational database.

Please refer these links for detail:

Guide Start Databases - Configuring a DB Connection Section

MSSQL PDO

StephenHy
  • 45
  • 9