2014-01-28 108 views
0

基本上我試圖在這裏做的是獲得基於某個領域的帖子,我已經使用了每個爲此,之後,我想要得到所有其他職位。我該怎麼做它?Yii CDbCriteria比較獲取所有值

$criteria=new CDbCriteria(array(
      'order'=>'create_time,likes DESC', 
       )); 

       foreach ($str_priority as $key=>$val) { 
        if($key!="") 
        $criteria->compare('tag',$key,true,'OR',true); 

       } 
        $criteria->compare('tag',"",true,'OR',true); 


      $total = Post::model()->count(); 
      $pages = new CPagination($total); 
      $pages->pageSize = 10; 
      $pages->applyLimit($criteria); 
      $posts = Post::model()->findAll($criteria); 
+0

等崗位是指不符合你條件的記錄? –

+0

@kumar_v是不符合條件的帖子 –

回答

0

你可以嘗試這樣這個 $criteria->addInCondition('tag', $str_priority, 'OR');