In Statement In Gridview

I’ve got a gridview, but I want to limit the results based on the Id.

Normally I’d do something like:




 Item::model()->FindAllByAttributes(array("id"=>array(1,2,3,4)));



But supplying an array like below doesn’t work as it expects a string, not an array;




$model=new Item('search');

$model->unsetAttributes();  // clear any default values

if(isset($_GET['Item']))

	$model->attributes=$_GET['Item'];


$model->id = array(1,2,3,4);



Is there a way I can do this?

please show your Item::search()-code

however, have a look at http://www.yiiframework.com/doc/api/1.1/CDbCriteria/#addInCondition-detail

try this on model searh function


$criteria->addInCondition('id',array(1,2,3,4,5,6));

Ah thanks, I solved it by doing this.




public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.

		$criteria=new CDbCriteria;

		

		if ($this->scenario === 'workset')

		{

			$set = $this->getWorkSet();

			$criteria->addInCondition('id', $set);

		}


		$criteria->compare('id',$this->id);

		//More compare items


		return $this->relatedSearch(

			$criteria,

			array()

		);

	}