How do you pass array parameter to $params in DB condition?

Hey.

Does Yii have a way to pass array parameter to $params when building a condition?

Regarding my case, I have something like:




$user2groups = User2group::model()

                        ->with('group')

                        ->with('group.project')

                        ->findAll('project.ID = :project_id AND t.REF_USER IN (:members)',

                            array(':project_id' => $project_id, ':members'=>implode(',', $members));



I’m trying to pass array of member ids (last row). The last try was to pass string with merged ids.

Still not working - returns only one row.

Any suggestions?

Thanks.

This is how to do it,

You have to supply the member id(s) array itself to the


addInCondition

,


$criteria = new CDbCriteria;

$criteria->compare('project.ID',$project_id);

$criteria->addInCondition('t.REF_USER',$members);


$user2groups = User2group::model()

                        ->with('group')

                        ->with('group.project')

                        ->findAll($criteria);

Thanks a lot, bro!

This is working as it should.