Error during tutorial/setup (CWebApplication.db is read only error)

Hi all… thanks in advance for the help…

I've installed the latest version of Yii and created my first webapp per the tutorial.

I added the 'db' section to my main.php as follows:

        //      Database

        'db' => array(

                'class' => 'CDbConnection',

                'emulatePrepare' => true,

                'autoConnect' => true,

                'persistent' => true,

                'connectionString' => 'mysql:host=localhost;dbname=xxx;',

                'username' => 'xxuser',

                'password' => 'xxuser',


However, when I run my site now, I'm getting an exception:



Property "CWebApplication.db" is read only.

Source File



  1. Why?

  2. Nobody else seems to be getting this?

  3. What did I do wrong?

If I remove the 'db' section from main.php, the exception goes away.

Help is appreciated.

Nevermind, I'm retarded.

'db' section needs to be under 'components' array. I had it at the top.


10x for information, it was userful

Thanks for the information.

It helped me too, thanks! :)