缓存错误:试图获取非对象的属性


Yii cache error: Trying to get property of non-object

我使用Yii PHP框架和MemCache进行缓存,当我第一次打开未缓存的页面时,我看到这个错误:

Live error error log off (linux):

Fatal error: Call to a member function getColumnNames() on a non-object in /home/cineshell/cineklik/framework/db/ar/CActiveFinder.php on line 385

本地错误日志(windows):

Trying to get property of non-object
C:'xampp'htdocs'appfolder'framework'yiilite.php(7125)
...
7123     public function getTableSchema()
7124     {
7125         return $this->getMetaData()->tableSchema;
7126     }

配置/主要:

    'cache'=> array(
        'class'=> 'CMemCache',
          'servers'=>array(
            array('host'=>'localhost', 'port'=>11211, 'weight'=>100),
          ),
    ),
缓存的例子:

$data = Yii::app()->cache->get( 'casheID'  );
if($data===false)
{
   $data = dataprovider, query... etc
}
echo $data;

那么,这里的错误是什么?,可能是服务器设置中的东西?

有人告诉我使用if isset,但我不明白!

对于CActiveDataProvider,请遵循本指南。http://www.yiiframework.com/wiki/233/using-cache-in-cactivedataprovider/

作为替代方案,您可以根据需要使用分段缓存gridview或部分视图。我也一直在挣扎,我发现查询缓存是唯一有效的解决方案。