Yii Framework Forum: Problem with ConsoleApplication - Yii Framework Forum

Jump to content

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

Problem with ConsoleApplication Rate Topic: -----

#1 User is offline   luis diego 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 02-February 10
  • Location:Costa Rica

Posted 31 May 2010 - 06:03 PM

I follow this instructions to make a new console application http://www.yiiframew.../topics.console

I supposed that I could use the defined models and use it to search information and made the things that I needed to do. But I got the following exception:

 exception 'CDbException' with message 'CDbConnection.connectionString cannot be empty.
Stack trace:
#0 /home/diego/public_html/yii-1.1.0.r1700/framework/db/CDbConnection.php(237): CDbConnection->open()
#1 /home/diego/public_html/yii-1.1.0.r1700/framework/db/CDbConnection.php(216): CDbConnection->setActive(true)
#2 /home/diego/public_html/yii-1.1.0.r1700/framework/base/CModule.php(357): CDbConnection->init()
#3 /home/diego/public_html/yii-1.1.0.r1700/framework/base/CApplication.php(391): CModule->getComponent('db')
#4 /home/diego/public_html/yii-1.1.0.r1700/framework/db/ar/CActiveRecord.php(526): CApplication->getDb()
#5 /home/diego/public_html/yii-1.1.0.r1700/framework/db/ar/CActiveRecord.php(1929): CActiveRecord->getDbConnection()
#6 /home/diego/public_html/yii-1.1.0.r1700/framework/db/ar/CActiveRecord.php(328): CActiveRecordMetaData->__construct(Object(Puesto))
#7 /home/diego/public_html/rh/protected/models/Puesto.php(23): CActiveRecord::model('Puesto')
#8 /home/diego/public_html/rh/protected/commands/cumplesCommand.php(21): Puesto::model()
#9 /home/diego/public_html/yii-1.1.0.r1700/framework/console/CConsoleCommandRunner.php(62): cumplesCommand->run(Array)
#10 /home/diego/public_html/yii-1.1.0.r1700/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#11 /home/diego/public_html/yii-1.1.0.r1700/framework/base/CApplication.php(135): CConsoleApplication->processRequest()
#12 /home/diego/public_html/yii-1.1.0.r1700/framework/yiic.php(31): CApplication->run()
#13 /home/diego/public_html/rh/protected/yiic.php(7): require_once('/home/diego/pub...')
#14 /home/diego/public_html/rh/protected/yiic(4): require_once('/home/diego/pub...')


Anyone want to help me?
0

#2 User is offline   tydeas_dr 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 158
  • Joined: 16-April 10
  • Location:Greece

Posted 31 May 2010 - 06:44 PM

First line of the exception says it as clean as possible
connectionString cannot be empty

That means in
your_project_di/protected/config/main.php

undert the
'db'=>...

You have an empty connection string. If you still issue this problem cp/paste this part of your confing/main.php
Follow me on twitter @dmtrsslvdr
Check my *new* blog @ tumblr
0

#3 User is offline   luis diego 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 02-February 10
  • Location:Costa Rica

Posted 31 May 2010 - 06:52 PM

I have the following the config/main.php

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


That isn't empty.

In protected folder root. I have the command which import the config file. The code of the command is the following:

<?php
defined('YII_DEBUG') or define('YII_DEBUG',true);
// include Yii bootstrap file
require_once('../../yii-1.1.0.r1700/framework/yii.php');
// create application instance and run
$configFile='config/main.php';

Yii::createConsoleApplication($configFile)->run();
?>


Could be that the command didnt read sucessfully the config file(main.php) but the path is correct..
0

#4 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 01 June 2010 - 01:40 AM

Maybe the path is mistaken.

Try using $config=dirname(__FILE__).'/config/console.php';

or main.php. This is how yiic command find the configuration.
1

#5 User is offline   luis diego 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 02-February 10
  • Location:Costa Rica

Posted 03 June 2010 - 10:42 AM

View Postzaccaria, on 01 June 2010 - 01:40 AM, said:

Maybe the path is mistaken.

Try using $config=dirname(__FILE__).'/config/console.php';

or main.php. This is how yiic command find the configuration.


Thanks man.
I missed the db configuration in the config/console.php

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

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