Answer the question
In order to leave comments, you need to log in
For joining 4 products in each category?
there is a request
$collections_sql = Yii::app()->db->createCommand()
->select('t.id, t.main_image, t.title, t.alias, t.sortOrder')
->from('tbl_collection (
SELECT * as c2 FROM tbl_catalog
) as t')
->join('tbl_gallery_photo gp', 'gp.gallery_id = t.id');
if(Yii::app()->request->getParam('model_id')){
$collections_sql->join('tbl_catalog c', 'c.gallery_photo_id = gp.id AND c.parent_model_id=:model_id',array(':model_id'=>Yii::app()->request->getParam('model_id')));
}else{
$collections_sql->join('tbl_catalog c', 'c.gallery_photo_id = gp.id');
}
$collections_sql->limit($count, ($page-1)*$count);
$collections_sql->order('sortOrder ASC');
$collections = $collections_sql->queryAll();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question