I have a grid view with a condition "upload_date = today", but when I search for other dates it is not filtering the grid. Here is my model:
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$date=date('Y-m-d');
$criteria=new CDbCriteria(array('order'=>'upload_date ASC'));
$criteria->condition = "upload_date='$date' ";
if(isset($_GET['upload_date']))
{
$criteria->addCondition('upload_date = :upload_date','AND');
$criteria->params[':upload_date'] = $this->upload_date;
}
$criteria->compare('book_id',$this->book_id);
$criteria->compare('date_received',$this->date_received,true);
$criteria->compare('batch',$this->batch,true);
$criteria->compare('isbn_no',$this->isbn_no,true);
$criteria->compare('book_title',$this->book_title,true);
$criteria->compare('auther_name',$this->auther_name,true);
$criteria->compare('upload_date',$this->upload_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>50
),
));
}
I am trying to use both condition and addcondition in same search. What did I do wrong in the model above?