0
에 CDBcriteria 만들기 :같은 쿼리 fo를 cdbcriteria을 만드는 방법 YII
select * from table_name where 'profile_type'='*'OR 'profile_type'=$usertype AND 'location'='*'OR 'location'=$country
에 CDBcriteria 만들기 :같은 쿼리 fo를 cdbcriteria을 만드는 방법 YII
select * from table_name where 'profile_type'='*'OR 'profile_type'=$usertype AND 'location'='*'OR 'location'=$country
직접 아래와 같은 조건을 전달할 수 있습니다.
참고 : 이것은 방법 중 하나입니다. 궁극적 인 해결책은 아닙니다.
$criteria = new CDbCriteria;
$criteria->condition = "(profile_type ='*' OR profile_type = $usertype) AND (location ='*' OR location = $country)";
$model = Model_name::model()->findAll($criteria);
이 같은 s 번째 시도 할 수 있습니다 : 당신은 당신이 따옴표로 조건을 포장해야한다고 생각
$criteria = new CDbCriteria;
$criteria->condition = "(profile_type='*' OR profile_type=:prof) AND
(location='*' OR location=:loc) ";
$criteria->params = array(':prof' => $usertype, ':loc' => $country);
$model = MyModel::model()->findAll($criteria);
청춘을? –
@ Letmesee Thanks. 내 코드를 업데이트했습니다. –
+1 이제 괜찮아 보이네 :) –