Perplexing tablePrefix

I’m new to the Yii framework. I created a table named ‘tbl_user’, had set the tablePrefix to ‘tbl_’ in main.php in the ‘db’ array. When I ran the model command from the yii shell script , I got the following:


[wwwtsid@fit ~/public_html/test/protected]$ php yiic shell ../index.php

Yii Interactive Tool v1.0 (based on Yii v1.0.11)

Please type 'help' for help. Type 'exit' to quit.

>> model *

exception 'CException' with message 'Property "CDbConnection.tablePrefix" is not defined.' in /home/wwwtsid/framework/base/CComponent.php:154

Stack trace:

#0 /home/wwwtsid/framework/YiiBase.php(204): CComponent->__set('tablePrefix', 'tbl_')

#1 /home/wwwtsid/framework/base/CModule.php(352): YiiBase::createComponent(Array)

#2 /home/wwwtsid/framework/base/CApplication.php(373): CModule->getComponent('db')

#3 /home/wwwtsid/framework/cli/commands/shell/ModelCommand.php(246): CApplication->getDb()

#4 /home/wwwtsid/framework/cli/commands/ShellCommand.php(144): ModelCommand->run(Array)

#5 /home/wwwtsid/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()

#6 /home/wwwtsid/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)

#7 /home/wwwtsid/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#8 /home/wwwtsid/framework/base/CApplication.php(135): CConsoleApplication->processRequest()

#9 /home/wwwtsid/framework/yiic.php(31): CApplication->run()

#10 /home/wwwtsid/public_html/test/protected/yiic.php(7): require_once('/home/wwwtsid/f...')

#11 /home/wwwtsid/public_html/test/protected/yiic(4): require_once('/home/wwwtsid/p...')

#12 {main}

>> exit



I renamed the table to ‘user’ (i.e. removed ‘tbl_’) and removed the tablePrefix entry from main.php. When I ran the model command again, it worked!


[wwwtsid@fit ~/public_html/test/protected]$ php yiic shell ../index.php

Yii Interactive Tool v1.0 (based on Yii v1.0.11)

Please type 'help' for help. Type 'exit' to quit.

>> model *

   generate User.php


The following model classes are successfully generated:

    User


If you have a 'db' database connection, you can test these models now with:

    $model=User::model()->find();

    print_r($model);




Any idea why I encountered this?

Here’s what I have in main.php.


'db'=>array(

      'class'=>'CDbConnection', 

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

      'emulatePrepare'=>true,

      'username'=> 'dbUser',

      'password'=> 'dbPassword',

      'charset' => 'utf8',

      'tablePrefix' => 'tbl_',

  ),

You should download version 1.1 instead of 1.0.