Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Compare Multiple Values In Model Search

$
0
0
Hello everybody and thanks for reading.

In my model i have a search function set up in the following way

public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;
                $criteria->order = "creation_date DESC";
                $criteria->compare('meeting_type',4);
               
                $criteria->compare('meeting_type',$this->meeting_type);
                

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

What the above code dose is filters all the meetings that are assigned a meeting_type of 4.
My question is how can i filter or search for multiple values , how can i search for more than one value for eg 4 and 5 and 6 eg $criteria->compare('meeting_type',4, 5, 6);<-wrong->
$criteria->compare('meeting_type',4)
$criteria->compare('meeting_type',5)
$criteria->compare('meeting_type',6)

Help will be most appreciated

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>