retrieve model->search() results

I’m new in Yii. How do I retrieve the rows returned by search in ‘admin’ pages? I’m looking for a procedure something similar to findAll()… Thanks

search() returns DataProvider which you can use to retrieve paged results. There is helper object you can use to iterate all record on all pages (http://www.yiiframework.com/doc/api/1.1/CDataProviderIterator):




$dataProvider = $model->search();

$iterator = new CDataProviderIterator($dataProvider);

foreach($iterator as $user) {

 echo $user->name."\n";

}



but where do i put that code to get hold of the values? search in cgridview seems like it is triggered by ajax.

where you will see model file there you will search public function like

public function search() {

  $criteria = new CDbCriteria;


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


  $criteria->compare('city', $this->city);





 return new CActiveDataProvider($this, array(


        'criteria' => $criteria,


        'pagination' => 10,


    ));

}

"name","city" are table field. please use like this

ajax is used to re-render whole page. search() is called either in controller action, or in view where grid/list is defined (usually index and admin views)