Brighton Madire Brighton Madire - 1 year ago 95
MySQL Question

Approving a message using Codeigniter

When on of the admin clicks an approve button its supposed to add the user_id of the person approving to a field in approval table

This is the button

<?php echo anchor('admin/messages/approve/'.$message->id.'', 'Approve', 'class="btn btn-success"'); ?>

This is the approve function in Controller

public function approve($id) {

$data = array(
'first_approval' => $this->session->userdata('user_id')

$this->Message_model->approve($id, $data);

//isset Message
$this->session->set_flashdata('success', 'Your approval was send');



This is the approve method inside the Model

public function approve($data) {

$this->db->join('messages', ' = approval.sms_id');

$this->db->where('id', 'sms_id');
$this->db->set('first_approval', $data);

I have sms_id, first_approval, second_approval and third_approval columns in my approval table but for now I'm just testing if I can put session->user_id in the column 'first_approval'

Answer Source

Change your approve method as following in MODEL

public function approve($id, $data) {
   $this->db->where('sms_id', $id);