它的工作更換$基準 - >獨特= TRUE;至$ criteria-> group ='store_id';
這是我的所有代碼希望有人從這裏找到幫助。
$criteria=new CDbCriteria;
//$criteria->distinct=true;
$criteria->group = 'store_id';
$criteria->select = 't.id,t.name,t.state,t.city,t.location,t.address,t.contact_no,t.email,t.facilities,t.profile_photo,t.description, t.merchant_id, t.approve, t.added_date';
$flag = false;
if(isset($_GET['Store']['category']) && !empty($_GET['Store']['category'])){
$criteria->compare('mmmStoreServices.category_id', $_GET['Store']['category']);
$flag = true;
}
if(isset($_GET['Store']['sub_category']) && !empty($_GET['Store']['sub_category'])){
$criteria->compare('mmmStoreServices.service_id', $_GET['Store']['sub_category']);
$flag = true;
}
if(isset($_GET['Store']['price']) && !empty($_GET['Store']['price'])){
$price = explode('-',$_GET['Store']['price']);
$minPrice = trim($price[0]);
$maxPrice = trim($price[1]);
$criteria->addBetweenCondition('mmmStoreServices.price', $minPrice, $maxPrice);
$flag = true;
}
if($flag){
$criteria->with = array('mmmStoreServices'); // Put `mmm_store_service` to relations of model 'Store'
$criteria->together = true; // Check if you really need this parameter!
}
if(isset($_GET['Store']['location']) && !empty($_GET['Store']['location'])){
$criteria->compare('t.location', $_GET["Store"]["location"]);
//$flag = true;
}
$criteria->compare('t.approve', 'Y');
$ajaxModel = new CActiveDataProvider('Store', array(
'criteria' => $criteria,
'pagination' => array('pageSize'=>'2'),
));
刪除鮮明並嘗試使用GROUP BY像'$基準 - >組=「STORE_ID」同列;' – 2014-09-26 07:06:05
由於它的工作 – aman 2014-09-26 07:15:38
我建議在這裏粘貼代碼,請確保您使用的findAll() ; – Rorschach 2014-09-26 07:15:54