public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
[b] $criteria->compare('year',2013);[/b]
$criteria->compare('surname',$this->surname,true);
$criteria->compare('name',$this->name,true);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'pagination'=>array('pageSize'=>100),
));
}
I changed this line
$criteria->compare(‘year’,$this->year);
to
$criteria->compare(‘year’,2013);
in order to parse for this current year only… now, I would like to be able to call this data set for other years…
what would be the proper way to set up my model in order for that to happen?
it works as is but I can only access 2013 data this way
There is nothing wrong here.What you have to do is set this value dynamically from your controller action and keep that line as it is.Like this is model search method
$criteria->compare('year',$this->year);
So, the only thing you need to do in controller action is.
$model = new YOURMODEL('search');
$model->year = "2011"; //Or you can set it dynamically.