Hi guys!
I use CGridView to display the goods from the shop. I tried to append a filter for them to display only goods with images. For that I have two models: Good and File. So my search method from Good model:
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('article',$this->article,true);
$criteria->compare('name',$this->name,true);
$criteria->compare('price',$this->price,true);
if ( $_GET['photo_exists'] ) {
$criteria->with = array('files' => array(
'condition' => 'file.id IS NOT NULL',
'together' => true,
));
}
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=> 40,
),
));
}
The result MySQL query from profiler ( SELECT section replaced by asterisk ):
SELECT *
FROM `good` `good`
LEFT OUTER JOIN `file` `file` ON (`file`.`oid`=`good`.`id`) AND (file.type = "GOOD")
WHERE (file.id IS NOT NULL)
ORDER BY good.id DESC, file.pos
LIMIT 40
The strange thing is displaying only 25 rows on the first page by CGridView, 16 on the second, and randomly further… The fact is I have about 250 records in database ( with the query I posted, if i run it - it returns exactly 40 rows ), but after the search method there are only about one hunded in summary from all pages.
Would you point me where I might be mistaken. Thank you.