Q:

How to Run Sql Server Update Statement with MVC

I want to update some values in my database table using Update statement using PHP with Sql Server 2008 R2.  Can anyone help me to do that ? 
Here is the code for that view class.  It has only one Button.  On Button Click I want to update value of settings
    <div class="box span12">
    <div class="box-header well">
    <h2><i class="icon-retweet"></i> Reset State</h2></div>
    <div class="box-content">

 <? php $form=$this->beginWidget('CActiveForm', array(
     'id'=>'systereset-form',
     'enableAjaxValidation'=>false,
     'htmlOptions'=>array('class'=>'form-horizontal'),
     )); ? >
  <fieldset>
    <legend>Please select State to reset</legend>
    <div class="form-actions">
    <? php echo CHtml::htmlButton('Reset State',array('class'=>'btn btn-primary','type'=>'submit','name'=>'systemreset')); ? >
</div>
<div class="row buttons">

</div>
</fieldset>
<? php $this->endWidget(); ? >

</div>

Here is Controller Class for this View Page
public function actionSystemReset(){
    if(isset($_POST['systemreset'])){
        $upd="update settings set value=0 where name='SYS_STATE_VALUE'";
        $update=Yii::app()->db->createCommand($upd)->execute();
        if($update>0){
            Yii::app()->user->setFlash('reset','Dear user Kiosk "'.$_POST['systemreset'].'"  has been reset successfully.'); 
        }
    }       
    $this->render('systemreset',array('result'=>$result));
}

A:

You have only a button and you don't have any name for this button so you can simply (avoid the check for $_POST['systemreset'])
public function actionSystemReset(){

    $upd="update settings set value=0 where name='SYS_STATE_VALUE'";
    $update = Yii::app()->db->createCommand($upd)->execute();
    if($update>0){
        Yii::app()->user->setFlash('reset','Dear user Kiosk "'.$_POST['systemreset'].'"  has been reset successfully.'); 

    }       
    $this->render('systemreset',array('result'=>$result));
}

