Yii, SQL query for matching multiple values in the same column

Hi… I need to fetch multi values on same column… I don’t know how to fetch it from YII?

I need the data x,y,a,b from following table?

How to fetch from sql query in YII criteria?

Plz?




id name designation  status

1   x      RJ         Active

2   y      VJ         Active

3   z      RJ         Pending

4   a      VJ         Active

5   b      VJ         Active



Something like this?




$dataInput = 'RJ & VJ';


$arrInput = explode(' & ', $dataInput);


$cr = new CDbCriteria();

foreach($arrInput as $i)

{

    $cr->addCondition('designation = "'.$$i.'"');

}


$items = Destination::model()->findAll($cr);



Thanks… But its not workout in my criteria. Anything else?

Post code where you make criteria.

I Tried the way what u said, but it shows undefined Variable RJ

How is it possible to declare it?

I need the data x,y,a,b from following table?

How to fetch from sql query in YII criteria?

Plz?




id name designation  status

1   x      RJ         Active

2   y      VJ         Active

3   z      RJ         Pending

4   a      VJ         Active

5   b      VJ         Active



There was an error, $$i instead $i




$dataInput = 'RJ & VJ';


$arrInput = explode(' & ', $dataInput);


$cr = new CDbCriteria();

foreach($arrInput as $i)

{

    $cr->addCondition('designation = "'.$i.'"');

}


$items = Destination::model()->findAll($cr);



echo count($items)= 0

Hi… I got a solution for this,





        $criteria = new CDbCriteria();

        $rj='RJ'; $vj='VJ';

        $criteria->condition = "(destination =:rdestination OR destination =:vdestination) AND status =:status ";

        $criteria->params = array(':rdestination'=>$rj,':vdestination'=>$vj,':status'=>'Active',);

        $records = test::model()->findAll($criteria);