$criteria->addCondition

I have the following and it works fine


$criteria->addCondition('TypeCode ="'.O.'"');

I need to have multiple options here though. If I have this in my controller it works fine




$model->TypeCode = array('A', 'C', 'P', 'S', 'V', 'Z');

I just need help getting this into an addCondition instead though. Failed attempt:


$criteria->addCondition('TypeCode ="'.array('A', 'C', 'P', 'S', 'V', 'Z').'"');

Try this: http://www.yiiframework.com/doc/api/1.1/CDbCriteria#addInCondition-detail




$criteria->addInCondition('TypeCode', array('A', 'C', 'P', 'S', 'V', 'Z'));



Thanks andy that works. I threw this into my app and it looked just like another attempt I had in there. Although I was using addCondition and not addInCondition.

You can use addCondition, but with many values it is not very handy. SQL IN operator is a better solution there.

i want join query addCondition

$criteria=new CDbCriteria;

$criteria->select=‘date,t.rollno,t.active, t.salary,t.name,t.id, ram_dbs.department’;

$criteria->join=‘INNER JOIN ram_dbs ON ram_dbs.id=t.id’;

$criteria->AddCondition(‘date’=$this->to_date);

RamDbf::model()->findAll($criteria);

is not work…ing

try to replace


$criteria->AddCondition('date'=$this->to_date);

with


$criteria->compare('date',$this->to_date);

Thank you.

hi you can use

$criteria->AddCondition(‘date =’.$this->to_date);