在 Yii 框架中配置数据库连接

2022-01-04 00:00:00 php mysql yii

在 Yii 框架的 main.php 文件中,有一些配置选项.这是它如何设置mysql

In the main.php file of the Yii framework, there are some configuration options. This is how it sets up mysql

'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=testdrive',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => 'root',
            'charset' => 'utf8',
        ),

在我的 MAMP 系统上,我必须将端口指定为 8889.我该如何将其添加到其中?

On my MAMP system, I have to specify the port as 8889. How would I add it into this?

谢谢

推荐答案

我像这样添加了端口,它似乎可以工作

I added the port like this and it seems to work

'db'=>array(
            'connectionString' => 'mysql:host=localhost;port=8889;dbname=testdrive',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => 'root',
            'charset' => 'utf8',
        ),

相关文章