2012-01-16 3 views
5

거의 모든 위키에서 간단한 것들이 설명되어 있습니다. 나는 yii의 CDbcriteria에 갇혀있다.yii의 문제점을 비교하십시오.

$criteria->compare('status','active'); 

그러나 내가 그것을 설명하는 예제 스크립트를 찾을 수 없습니다 :이 비교 설명

select * from users where status ='active' 

:

만 일치 "동일은"에 대한 을 정확하게 설명하는 연산자 기반 검색. 다음 검색어와 같지 않음 :

select * from users where status !='active' 

어떻게하면됩니까? 다른 status NOT IN ('active', 'smth else')

+4

나는 이것을 +1 투표하기 위해 로그인했습니다. 왜 사람들이 이것을 downvoting하는 지 알 수 없습니다. –

+0

@FelipeAlmeida, 대단히 감사합니다. –

답변

5

$criteria->condition = " status<>'active'"; 
$criteria->compare('status',$this->status,true); 
4

$criteria->addNotInCondition('status', array('active'));

같은 몇 가지 일을하려고 나는 아래의 3 컨디셔너했다 매력처럼 작동합니다 :

$criteria->condition='employee_id<>:employee_id AND vehicle_id=:vehicle_id AND checked_in_on IS NULL'; 
      $criteria->params=array(':employee_id'=>Yii::app()->session['activity']->employee_id,':vehicle_id'=>$model->id); 
      $checkedOutVehicleBySomeoneElse = Activity::model()->find($criteria); 
1

count(array('active')) === 1 SQL 것이다 status != 'active'

$criteria->addCondition("NOT status = 'active'"); 
1

을 시도하는 경우