Yii Framework Forum: Perplexing tablePrefix - Yii Framework Forum

Jump to content

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

Perplexing tablePrefix Rate Topic: -----

#1 User is offline   J. Michael Moore 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 09-January 10

Posted 14 February 2010 - 10:40 PM

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_',
  ),



J. Michael Moore
TSID Webmaster
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,891
  • Joined: 04-October 08
  • Location:DC, USA

Posted 14 February 2010 - 10:47 PM

You should download version 1.1 instead of 1.0.
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