0

I'm a yii programmer...

I have 2 variables and I want to check if the first variable exists in the the city column and the second variable in type "OR" category column.

I did this and it doesn't work :

$criteria = new CDbCriteria(array(
'condition'=>'published="true"'
));

if(isset($_GET['city']) || isset($_GET['word']))
{
   if(!empty($_GET['city']) )
      $criteria->addSearchCondition('city',$_GET['city'] , true, 'AND');
   if(!empty($_GET['word']) ){
      $criteria->addSearchCondition('type',$_GET['word'] , true, 'OR');
      $criteria->addSearchCondition('category',$_GET['word'] , true, 'OR');

   }
}

And only rows with published=true will be displayed...

As a result i get rows that doesn't meet my criteria..

Where is the problem please help thanks

4

1 回答 1

0

由于 addCondition 用于将新条件与旧条件与您提供的运算符相连接,并且您希望拥有 c1 AND c2 OR c3,因此您的第二个运算符应该是与运算符。

于 2012-09-16T01:04:03.403 回答