I have a behavior attached to a model and it makes the CActiveDataProvide not count properly (it says in the pagination that it has all the records in the database)
From looking around the source code, I think it probably deals with calculateTotalItemCount() but a little stumped on creating a patch (and not too sure if it’s a bug or intended this way).
If it is intended this way I am probably going to just create a custom class that extends CActiveDataProvide to provide a fix for my models but wondering what I should change to make it work properly.
Here is a simplified version of the Behavior:
class MyBehavior extends CActiveRecordBehavior{
function afterConstruct( $event ){
$condition = $this->owner->getDbCriteria();
$condition->compare( $this->owner->getTableAlias() .'.active', 1 );
}
}
Table
id active
1 1
2 0
3 1
4 0
So in the Controller:
class TableController extends CController{
actionIndex(){
$dataProvider = CActiveDataProvider( 'Table' );
$this->render( 'index', array( 'dataProvider' => $dataProvider ) );
}
}
Expected results: "Displaying 1-2 of 2 result(s)."
Results I am getting: "Displaying 1-2 of 4 result(s)."
Yii Version: 1.1.12
OS: Windows 7 32bit
DB: MySQL 5.5.20
PHP: 5.3.9
Webserver: Apache 2.2.21