Where part of Yii2 I connect to the database

Asked

Viewed 155 times

0

In the Yii2 Framework application I’m using the "Advanced" template, I’m having difficulty making the connection.

Where the framework is connected to the mysql database?

1 answer

0

The file that should declare database connection is main-local.php The print below shows the exact place where it is.

Print da estrutura da Yii2 Advanced

Inside the file you should find something like this.

'components' => [
    'db' => [
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost;dbname=nome_base_de_dados',
        'username' => 'nome_utilizador',
        'password' => 'password_base_de_dados',
        'charset' => 'utf8',
    ],
],

Where only database access data should be changed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.