i have a gridview with search option by a database table.All working fine but the problem is when i enter a id value to search my grid it shows all the related value rows. For example if i enter value “1” it filters all 1’s like 1,10,11,12,13,….
But i need to show only exact value what i entered it should show only the corresponding row i hope u understand my prob…
my model is like below
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria(array('order'=>'proc_id DESC'));
//$criteria->condition = " status = 'Active' ";
$criteria->compare('proc_id',$this->proc_id);
$criteria->compare('book_id',$this->book_id,true);return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>50
),
));
}
hi i found the answer for my problem i just removed true from my code as below
$criteria->compare('book_id',$this->book_id);
You can set up any kind of mySql WHERE condition you want like this:
You should be able to use compare() though, but you might have to cast the ID to an integer: