gii CDbException

I am trying to create a simple web application using yii. I have install WAMP and yii. I am also created a skeleton application called yii test. I have also created a database with mysql called yiitest which has a table called persons and has the following columns: pid, fname, lname, dob, zip. I am trying to build the basic functionality of the web app using gii. I can log into gii and navigate to Controller Generator Form Generator and Module Generator, but when I try to click on Crud Generator or Model Generator I get a CDbException error.

Here is my code:

protected/config/database.php




<?php


// This is the database connection configuration.

return array(

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

	// uncomment the following lines to use a MySQL database

	

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

	'emulatePrepare' => true,

	'username' => 'yiiUser',

	'password' => 'p4ssw0rd',

	'charset' => 'utf8',

	

);



protected/config/main.php




<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

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

	'name'=>'My Web Application',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'password',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

		

	),


	// application components

	'components'=>array(


		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),


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

		

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

		


		// database settings are configured in database.php

		'db'=>require(dirname(__FILE__).'/database.php'),


		'errorHandler'=>array(

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

			'errorAction'=>'site/error',

		),


		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

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

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),


	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);



Any help on getting gii’s Model Generator and Crud Generator working would be very helpful!

The configuration looks fine to me, but what error message do you get exactly?

Thanks for your response! This is a straight copy from the page. Also I have attached a picture

CDbException

C:\wamp\www\yii\framework\gii\generators\model\ModelCode.php(60)

48 ));

49 }

50

51 public function requiredTemplates()

52 {

53 return array(

54 ‘model.php’,

55 );

56 }

57

58 public function init()

59 {

60 if(Yii::app()->{$this->connectionId}===null)

61 throw new CHttpException(500,‘A valid database connection is required to run this generator.’);

62 $this->tablePrefix=Yii::app()->{$this->connectionId}->tablePrefix;

63 parent::init();

64 }

65

66 public function prepare()

67 {

68 if(($pos=strrpos($this->tableName,’.’))!==false)

69 {

70 $schema=substr($this->tableName,0,$pos);

71 $tableName=substr($this->tableName,$pos+1);

72 }

The database connection is not established.

Are you sure you have installed php_pdo and php_pdo_mysql?