EActiveDataProviderEx enhance the CActiveDataProvider class by:
- adding the new query caching feature introduced in Yii 1.1.7
- circumventing the issue of miscalculation of the number of elements when a
having
and / orgroup
criteria is used by the active record
Requirements ¶
Yii 1.1.7 or later
Installation ¶
Extract the release file under protected/components
Be sure to import the component using the 'import' parameter of the config file
Usage ¶
Use EActiveDataProviderEx the exact same way you use CActiveDataProvider.
In addition, you can specify a cache
property as an array consisting in two parameters: array($cache_duration, $cache_dependency)
.
$cache_duration
is the cache duration in seconds
$cache_dependency
is an optional CCacheDependency object
Example ¶
$criteria=new CDbCriteria;
// add some criteria here
$dependency = new CDbCacheDependency('SELECT MAX(UNIX_TIMESTAMP(`modified`)) FROM yourModelTable'); // Optional
$activeDataProviderEx = new EActiveDataProviderEx(yourModel, array(
'criteria'=>$criteria,
'pagination' => array('pageSize' => 30),
'sort' => array('defaultOrder' => '`t`.`name`'),
'cache' => array(3600, $dependency)
));
Change log ¶
Version 1.1.1
- Fix for criterias not being retrieved from cache (small fetchData overloading)
Version 1.1.0
- Better native cache support (thanks to Stamm, see http://www.yiiframework.com/wiki/233/using-cache-in-cactivedataprovider/)
- fetchData method is no more overloaded
- calculateTotalItemCount optimisation
Version 1.0.0
- Initial release
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.