Yiic shell and database configuration

Are there any instructions on how to configure database access for the yiic command in version 1.0.6?

I tried different things, but none of them worked:

Tried the following protected/config/console.php file:

<?php





// This is the configuration for yiic console application.


// Any writable CConsoleApplication properties can be configured here.


return array(


    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


    'name'=>'My Console Application',


    'db'=>array(


        'class' => 'CDbConnection',


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


        'charset' => 'UTF8',


        'username'=>'root',


        'password'=>'root',


    ),


);

However, I get the following error if I run "protected/yiic shell" from the command line:

exception 'CException' with message 'Property "CConsoleApplication.db" is read only.' in /Library/WebServer/Documents/apps/FeedProxy/framework/base/CComponent.php:151

Is there any reason why the yiic shell can't just look at my "protected/config/main.php" file for figuring out the database connection?

Cheers,

pieter

'db' should be put in 'component' array

When I do that and change the configuration in "protected/config/console.php" to:

<?php





// This is the configuration for yiic console application.


// Any writable CConsoleApplication properties can be configured here.


return array(


    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


    'name'=>'My Console Application',


    'components' => array(


        'db'=>array(


            'class' => 'CDbConnection',


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


            'charset' => 'UTF8',


            'username'=>'root',


            'password'=>'root',


        ),


    ),


);

then I get the following message:

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /Library/WebServer/Documents/apps/FeedProxy/framework/db/CDbConnection.php:248


Stack trace:


#0 /Library/WebServer/Documents/apps/FeedProxy/framework/db/CDbConnection.php(223): CDbConnection->open()


#1 /Library/WebServer/Documents/apps/FeedProxy/framework/db/CDbConnection.php(202): CDbConnection->setActive(true)


#2 /Library/WebServer/Documents/apps/FeedProxy/framework/base/CModule.php(353): CDbConnection->init()


#3 /Library/WebServer/Documents/apps/FeedProxy/framework/base/CApplication.php(338): CModule->getComponent('db')


#4 /Library/WebServer/Documents/apps/FeedProxy/framework/cli/commands/shell/ModelCommand.php(267): CApplication->getDb()


#5 /Library/WebServer/Documents/apps/FeedProxy/framework/cli/commands/ShellCommand.php(136): ModelCommand->run(Array)


#6 /Library/WebServer/Documents/apps/FeedProxy/framework/cli/commands/ShellCommand.php(96): ShellCommand->runShell()


#7 /Library/WebServer/Documents/apps/FeedProxy/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)


#8 /Library/WebServer/Documents/apps/FeedProxy/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)


#9 /Library/WebServer/Documents/apps/FeedProxy/framework/base/CApplication.php(133): CConsoleApplication->processRequest()


#10 /Library/WebServer/Documents/apps/FeedProxy/framework/yiic.php(31): CApplication->run()


#11 /Library/WebServer/Documents/apps/FeedProxy/protected/yiic.php(7): require_once('/Library/WebSer...')


#12 /Library/WebServer/Documents/apps/FeedProxy/protected/yiic(4): require_once('/Library/WebSer...')


#13 {main}


The same connection information is in my "protected/config/main.php" and is working just fine.

Cheers,

pieter

Fixed, there was some mixup with the php.ini that was being looked at.

@pclaerhout, how did you fix it exactly,becoz I’m running into the same exception and have also added the db settings but still the same exception.So I would appreciate if you could explain further on the php.ini mix up