Cdbcommand binding array for SQL IN clause

I want to have something like

$some_values = array(1,2,3,4,5);

Yii::app()->getDb()->createCommand('SELECT x FROM y WHERE z in (:p1)')->bindValuesForInClause(':p1'=>$some_values)->queryAll();

use findAll()

Not an answer.

I have some really huge queries with some IN clauses written on pure pl/sql.AR not a solution here.

If you can use the query builder,

Maybe idea from Stackoverflow will be helpful.

Thanks for replies.

BUT is this will not be useful if yii will do it automatically?

This functionallity included in Yii2

Having come across this problem a few times in my projects I have come-up with the following Yii work-around using CDbCriteria which is a little hacky, but gives the security of param count matching.

When applied to your example my code would be:

$some_values = array(1,2,3,4,5);

$criteria = new CDbCriteria();


$sql = 'SELECT x FROM y WHERE '.$criteria->condition;

$command = Yii::app()->db->createCommand($sql);

$results = $command->queryAll(true, $criteria->params);