Answer the question
In order to leave comments, you need to log in
How to merge CDbCriteria in Yii 1?
Hello! Wanted to combine the conditions.
$criteriaCompare = new CDbCriteria();
$criteriaCompare->with = array('manufacturer');
$criteriaCompare->compare('manufacturer.archive' , 'n');
$criteriaCondition = new CDbCriteria();
$criteriaCondition->order = 'RAND()';
$criteriaCondition->limit = self::SIDEBAR_LIDERS_COUNT;
$criteriaCondition->addCondition("of_month = '" . self::OF_MONTH_YES . "'");
$criteriaCondition->addCondition("category_id = '$category->id'");
$criteriaCondition->addCondition("archive = '" . self::ARCHIVE_NO . "'");
//Объединяем критерии
$criteriaCompare->mergeWith($criteriaCondition);
$products = Product::model()->findAll($criteriaCompare);
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