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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6121908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:24:32  来源:igfitidea点击:

configuring database connection in Yii framework

phpmysqlyii

提问by Leahcim

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

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

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

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

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

thanks

谢谢

回答by Leahcim

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',
        ),

回答by martynthewolf

can you not add it here to your connectionString

你能不把它添加到你的 connectionString 吗

'connectionString' => 'mysql:host=localhost;dbname=testdrive;port=8889',

'connectionString' => 'mysql:host=localhost;dbname=testdrive;port=8889',