Cdbexception Error[ Urgent ]

Hi,

I am new to Yii, my main issue is some times Yii throws CDbException error. It says

The table "project" for active record class "Projects" cannot be found in the database. But when I refresh the page it works fine. If I refresh the page 10-15 times I get this error. I cheked my controller, model etc every thing works fine.

Please help me, its urgent

this is the error

CDbException

The table "project" for active record class "Projects" cannot be found in the database.

/home/linxysin/public_html/pms/framework/db/ar/CActiveRecord.php(2362)

2350

2351 /**

2352 * Constructor.

2353 * @param CActiveRecord $model the model instance

2354 * @throws CDbException if specified table for active record class cannot be found in the database

2355 */

2356 public function __construct($model)

2357 {

2358 $this->_modelClassName=get_class($model);

2359

2360 $tableName=$model->tableName();

2361 if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)

2362 throw new CDbException(Yii::t(‘yii’,‘The table “{table}” for active record class “{class}” cannot be found in the database.’,

2363 array(’{class}’=>$this->_modelClassName,’{table}’=>$tableName)));

2364 if($table->primaryKey===null)

2365 {

2366 $table->primaryKey=$model->primaryKey();

2367 if(is_string($table->primaryKey) && isset($table->columns[$table->primaryKey]))

2368 $table->columns[$table->primaryKey]->isPrimaryKey=true;

2369 elseif(is_array($table->primaryKey))

2370 {

2371 foreach($table->primaryKey as $name)

2372 {

2373 if(isset($table->columns[$name]))

2374 $table->columns[$name]->isPrimaryKey=true;

My best guess is that you have a limit on the number of queries you can do in parallel on your db server and that your query fails for that.

Try to enable caching.

In my configuration I use the following where $isProduction identifies whether this is on my dev machine or not.


                'cache'=>$isProduction?

                array(

                        'class'=>'CApcCache',

                ):

                array(

                        'class'=>'CDbCache',

                        'connectionID'=>'db',

                        'cacheTableName'=>'cache',

                        //'keyPrefix'=>'app',

                ),

You also have to enable ‘schemaCaching’ in your db.

My configuration is like this:


                'db'=>($isProduction?

                        array(

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

                                'emulatePrepare' => true,

                                'username'=>'real_user', 'password'=>'real_password',

                                'charset' => 'utf8',

                                'tablePrefix' => '',

                                'schemaCachingDuration'=>3600,

                                'initSQLs'=>array("set time_zone='+00:00';"), // Make SQL server return DATETIME as UTC

                        )



The ‘schemaCachingDuration’ is set to 1 hour in my case.

Thanks for your help, I think its working now. I need to test it properly