Yii Framework Forum: Yiic shell and database configuration - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yiic shell and database configuration Rate Topic: -----

#1 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 11 June 2009 - 01:59 PM

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
0

#2 User is offline   will 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 179
  • Joined: 21-March 09

Posted 11 June 2009 - 02:04 PM

'db' should be put in 'component' array
0

#3 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 12 June 2009 - 02:15 AM

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
0

#4 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 12 June 2009 - 05:45 AM

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

#5 User is offline   Russel Mupfumira 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 08-July 13

Posted 22 July 2013 - 02:38 PM

View Postpclaerhout, on 12 June 2009 - 05:45 AM, said:

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users