Hi there,
I’ve followed this tutorial
And it works really nice, but not completely.
The problem is that when I load the admin file the default value of the count is set at 0, so in the filter input type is a zero. Is this something by default or did I made a mistake?
List.php
* @property integer $lijstItemsCount
* @property integer $gedeeldCount
public function rules(){
return array(
...,
array('... lijstItemsCount, gedeeldCount', 'safe', 'on'=>'search'),);
}
public function relations()
{
return array(
...
'lijstItemsCount' => array(self::STAT, 'LijstItem', 'lijst_id'),
'gedeeldCount' => array(self::STAT, 'KoppelUserLijst', 'list_id'),
);
}
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$lijstItemTable = LijstItem::model()->tableName();
$koppelTable = KoppelUserLijst::model()->tableName();
$wensen = "(select count(*) from ". $lijstItemTable ." where ". $lijstItemTable .".lijst_id = t.id)";
$gedeeld = "(select count(*) from ". $koppelTable ." where ". $koppelTable .".list_id = t.id)";
$criteria=new CDbCriteria;
$criteria->select = array(
'*',
$wensen . " as lijstItemsCount",
$gedeeld . " as gedeeldCount",
);
...
$criteria->compare($wensen, $this->lijstItemsCount);
$criteria->compare($gedeeld, $this->gedeeldCount);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination' => array(
'pageSize' => 50,
),
));
}
Hope someone can help.
Thanks in advance!