demo application problems


I’m new with PHP and Yii and I was trying to rub Model and CRUD generator from Yii demo application. In both cases I get this:


CDbConnection.connectionString cannot be empty.


32         ));

33     }


35     public function requiredTemplates()

36     {

37         return array(

38             'controller.php',

39         );

40     }


42     public function init()

43     {

44         if(Yii::app()->db===null)

45             throw new CHttpException(500,'An active "db" connection is required to run this generator.');

46         parent::init();

47     }


49     public function successMessage()

50     {

51         $link=CHtml::link('try it now', Yii::app()->createUrl($this->controller), array('target'=>'_blank'));

52         return "The controller has been generated successfully. You may $link.";

53     }


55     public function validateModel($attribute,$params)

56     {

THis demo came with latest stable version. I have check content of connectionString and it matches the real data, like port, database name. Database is started and accessible with phpadmin. What could be wrong?

Could you post the ‘db’ part of your /config/main.php file please? Other things to check are:

the login details are correct, and you can log in to your database with exactly the same credentials as you have in main.php

The ‘db’ settings are actually pointing to use MySQL (the default is sqlite)

Sure, here is actually the complete components array:



			// enable cookie-based authentication



		// uncomment the following to enable URLs in path-format














			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',




		// uncomment the following to use a MySQL database



//		'connectionString' => 'mysql:host=;dbname=trackstar_dev;port=8889;',

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

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => 'root',

			'charset' => 'utf8',



			// use 'site/error' action to display errors








					'levels'=>'error, warning',


				// uncomment the following to show log messages on web pages








OK - If you open up "Terminal" from /Applications/Utilities and type in

mysql -uroot -proot -h127.0.0.1 -P8889

do you get a connection error?


Does it work if you comment out the db part for mysql, and uncomment the part for sqlite? Trying to work out if it’s an error with your config file, as this error should only appear when no connectionString has been specified.