This extension for Yii framework will permit you to construct grids in a easy way, just write the parameters array and the widget will show the table. Each time is better!!
public function actionMultidelete()
{
$this->_model=Users::model()->deleteAll("id IN (" .implode(",",$_POST["cid"]).")");
$this->redirect(array('list'));
}
public function actionMultipublish()
{
$this->_model=Users::model()->updateAll(array("state"=>1),"id IN (" .implode(",",$_POST["cid"]).")");
$this->redirect(array('list'));
}
public function actionMultiunpublish()
{
$this->_model=Users::model()->updateAll(array("state"=>0),"id IN (" .implode(",",$_POST["cid"]).")");
$this->redirect(array('list'));
}
protected function processAdminCommand()
{
if(isset($_POST['command'], $_POST['id'])) {
switch($_POST['command']) {
case 'delete': $this->loadUsers($_POST['id'])->delete(); break;
case 'publish':
$model= $this->loadUsers($_POST['id']);
$model->state=1;
$model->save();
break;
case 'unpublish':
$model= $this->loadUsers($_POST['id']);
$model->state=0;
$model->save();
break;
}
$this->refresh();
}
}