CActiveDataProvider & IN condition

I have a problem retrieving multiple rows using multiple keys with CActiveDataProvider, I tried:


		$details = new CActiveDataProvider('TransactionDetail', array(

			'criteria' => array(

				'condition' => 't.id IN (:itemId)',

				'params' => array(':itemId' => '49,50'), //hardcoded string

				'with' => 'item',

			),

			'pagination' => array(

				'pageSize'=>self::PAGE_SIZE,

			),

		));

and


		$details = new CActiveDataProvider('TransactionDetail', array(

			'criteria' => array(

				'condition' => 't.id IN (:itemId)',

				'params' => array(':itemId' => array(49,50)), //array

				'with' => 'item',

			),

			'pagination' => array(

				'pageSize'=>self::PAGE_SIZE,

			),

		));

The first only returns itemId 49, whereas the second code returns nothing, is there a solution for this?

I also tried this:


		$criteria = new CDbCriteria;

		$criteria->with = 'item';

		$criteria->addInCondition('itemId',array(49,50));


		//load the details

		$details = new CActiveDataProvider('TransactionDetail', array(

			'criteria' => $criteria,

			'pagination' => array(

				'pageSize'=>self::PAGE_SIZE,

			),

		));

But I got nothing…

You have set ‘itemId’ as first parameter in $criteria->addInCondition, shouldn’t that be ‘t.id’?

Since it’s been 17 days you may have found your answer (krisnod is right), anyway as I had the same problem finding the IN syntax I’ll share with the others.

Don’t even try the first two examples. You HAVE to use addInCondition which will internally explode each “IN” element and accordingly create SQL params.