0

Probably a similar topic on the web, but it was a difficult search. I got thousand of results, but none with the exact problem i have.

So im working in Yii, and i need a query to give me the following.

One column must be equal to $firsvariable and another column must be equal to $seconvariable OR $thirdvariable. The second column has only 3 options in a enum.

Now, i've tried several different approches, and tried to read up on CDbCriteria Class reference, but no luck so far.

Ive tried

$criteria=new CDbCriteria;
$criteria->condition = "column1=".$firstvariable;
$criteria->addCondition('column2!= 2', 'AND');

and

$criteria=new CDbCriteria;
$criteria->condition = "column1=".$firstvariable;
$criteria->addCondition('(column2 = 0 OR column2 = 1)', 'AND');

And several more.

4

1 回答 1

1

尝试这个:

    $criteria = new CDbCriteria();
    $criteria->addCondition('column1 = value1');
    $criteria->addCondition('column2 = value2 OR column2 = value3');

它应该工作。

于 2013-07-03T17:38:10.850 回答