如果另一列发布了(Codeigniter)PHP,则更新另一列

I have this simple code that display only 2 column (step and feedback) so whenever the "feedback" has submited or post like in my controller below and the "step" column would count like $step+=1 or update with query update my_table set step = step + 1 where id = $user_id ,,which is if "feedback" has submited the "step" column always increment ++ .

controllers/Person.php

public function ajax_update()
    {
        $data = array(

                //'step' => $this->input->post('step'),
                'feedback' => $this->input->post('feedback'),
            );
        $this->person->update(array('user_id' => $this->input->post('user_id')), $data);
        echo json_encode(["status" => TRUE]);
    } 

Model/Person_model.php

public function update($where, $data)
{
    $this->db->update($this->table, $data, $where);
    return $this->db->affected_rows();
}

Views/person_view.php

 <div class="form-group">
     <label class="control-label col-md-3">kcp naem</label>
          <div class="col-md-9">
             <input name="feedback" placeholder="status" class="form-control" type="text">
               <span class="help-block"></span>
          </div>
 </div> 

   <button type="button" id="btnSave" onclick="save()" class="btn btn-primary">Save</button>

plus jquery ajax for button save()

function save()
{
    $('#btnSave').text('saving...'); //change button text
    $('#btnSave').attr('disabled',true); //set button disable 
    var url;

        url = "<?php echo site_url('person/ajax_update')?>";

    // ajax adding data to database
    $.ajax({
        url : url,
        type: "POST",
        data: $('#form').serialize(),
        dataType: "JSON",
        success: function(data)

    });
}

maybe we should just focus on the controller and model . Some assistance would be great on how to setup the update.

Thankyou

You can do this in qb using the following method:

$this->db->set('step', 'step+1', FALSE);
$this->db->where('user_id', $user_id);
$this->db->update('tablename');

https://www.codeigniter.com/userguide3/database/query_builder.html#updating-data


// controller
public function ajax_update() {
    $feedback = $this->input->post('feedback');
    $uid = $this->input->post('user_id');
    if (!is_null($feedback) && !is_null($uid)) {
        // only increment: "whenever the "feedback" has submited or post"
        $this->person->update_feedback($uid, $feedback);
        echo json_encode(["status" => TRUE]);
    } else {
        echo json_encode(['status' => FALSE]); //?
    }
}

// model
public function update_feedback($user_id, $feedback) {
    $this->db->set('step', 'step+1', FALSE);
    $this->db->set('feedback', $feedback);
    $this->db->where('user_id', $user_id);
    $this->db->update($this->table);
    return $this->db->affected_rows();
}