Yii 1.1: eactivedataproviderex

Some CActiveDataProvider enhancements (query caching, total item count fix)

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 / or group criteria is used by the active record


Yii 1.1.7 or later


Extract the release file under protected/components
Be sure to import the component using the 'import' parameter of the config file


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


$criteria=new CDbCriteria;
// add some criteria here
$dependency = new CDbCacheDependency('SELECT MAX(UNIX_TIMESTAMP(`modified`)) FROM yourModelTable'); // Optional
$activeDataProviderEx = new EActiveDataProviderEx(yourModel, array(
     '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


Be the first person to leave a comment

Please to leave your comment.

Create extension