无法将数组绑定到CDbCriteria(Yii)

I want to use WHERE IN(array) clause in my query.

$criteria = new CDbCriteria;
$criteria->addCondition('id_cty_cmp IN(:ids)');
$criteria->params = array(':ids' => $ids); // binding array

$cmps = Component::model()
            ->with(array('type', 'values'))
            ->findAll($criteria);

Like this, I get "Array to string conversion" error.

When I used

$criteria->params = array(':ids' => implode(',', $ids));

I got nothing (empty array).

When I don't use binding, it works (but clearly not a good practice):

$criteria = new CDbCriteria;
$criteria->addCondition('id_cty_cmp IN(' . implode(',', $ids) . ')');

Any ideas?

Alright, here's the solution. May it help future googlers.

$criteria = new CDbCriteria;
$criteria->addInCondition('id_cty_cmp', $ids);

Just in case you are wondering, the reason that

$criteria->params = array(':ids' => implode(',', $ids));

fails to return any records is because :ids will be bound with one string like this:

id_cty_cmp IN('1,2,3')

Clearly no id_cty_cmp matches the weird value '1,2,3'.

How you want it, which your solution provides, is:

id_cty_cmp IN('1','2','3')