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',
    ],
1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.