Search don't work [solved]

This search function gives the data in two diferent ways to a CGridView.

When fromUserStb = false, all works fine, but when fromUserStb = true, the initial showed data it’s OK but when I try to search using the search fields of the CGridView nothing happens.

Can you help me?

public function search()

{


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


	// should not be searched.





	$criteria=new CDbCriteria;





	$criteria->compare('id_user',$this->id_user,true);


	$criteria->compare('name',$this->name,true);


	$criteria->compare('surname',$this->surname,true);


	$criteria->compare('email',$this->email,true);


	$criteria->compare('phone',$this->phone,true);


	$criteria->compare('fc_delete',$this->fc_delete,true);





	if(!$this->fromUserStb){


		


		return new CActiveDataProvider($this, array(


				'criteria'=>$criteria,


		));


		


	}else{


		


		$criteria->condition='fc_delete IS NULL';


		


		return new CActiveDataProvider($this, array(


				'criteria'=>$criteria,


				'pagination'=>array(


						'pageSize'=>4,


				)


		));


		


	}


	


	


}

Kind regards.

it is quite easy… when $this->fromUserStb == true you overwrite search condition…

all functions “compare” and “add*Condition” simply modify ‘condition’ attribute of criteria object. So when you overwrite it with:

$criteria->condition=‘fc_delete IS NULL’;

only this condition is applied. change it to:

$criteria->addCondition(‘fc_delete IS NULL’);

Thx redguy! It worked.