Home » Php » php – configuring database connection in Yii framework

php – configuring database connection in Yii framework

Posted by: admin July 12, 2020 Leave a comment

Questions:

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

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

thanks

How to&Answers:

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

Answer:

can you not add it here to your connectionString

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