首页 > 解决方案 > 更新两个表以生成发票和激活用户

问题描述

我需要在激活mobile_no两个表中作为外键的用户时生成发票。我有两个表需要更新如下

表格1CI_USER

is_active = 0/1 mobile_no

表2VOUCHER

mobile_no voucher_no | Auto Increment voucher_date

voucher_amount reward1_amt reward2_amt is_reward1

is_reward2 reward1_date reward2_date

但我在功能或控制器方面遇到了一些问题,所以请为我提供任何解决方案

模型

public function edit_user($data, $id){
         $this->db->set($data);
         $this->db->where('ci_users.id', $id);
         $this->db->where( 'voucher.id', $id );       
         $this->db->update(array('ci_users as a', 'voucher as b'));
        return true;
    }

控制器

public function activate($id = 0)($mobile_no = mobile_no){
        if($this->input->post('submit')){
            $this->form_validation->set_rules('voucher_amount', 'Voucher Amount', 'trim|required');
            $this->form_validation->set_rules('status', 'Status', 'trim|required');

            if ($this->form_validation->run() == FALSE) {
                $data['user'] = $this->Activate_member_model->get_user_by_id($id);
                $data['user_groups'] = $this->Activate_member_model->get_user_groups();
                $data['view'] = 'admin/Activate_member/member_edit';
                $this->load->view('layout', $data);
            }
            else{
                $data = array(
                    'mobile_no' => $this->session->userdata('mobile_no'),
                    'voucher_amount' => $this->input->post('voucher_amount'),
                    'is_active' => $this->input->post('status'),
                    'updated_at' => date('Y-m-d : h:m:s'),
                    'voucher_date' => date('Y-m-d : h:m:s'),
                    'voucher_no' => $this->input->post('voucher_no'),
                );
                $data = $this->security->xss_clean($data);
                $result = $this->Activate_member_model->edit_user($data, $id);
                if($result){
                    $this->session->set_flashdata('msg', 'User has been updated successfully!');
                    redirect(base_url('admin/Activate_member'));
                }
            }
        }
        else{
            $data['user'] = $this->Activate_member_model->get_user_by_id($id);
            $data['user_groups'] = $this->Activate_member_model->get_user_groups();
            $data['view'] = 'admin/Activate_member/member_edit';
            $this->load->view('layout', $data);
        }
    }

如果像这样调用 1 个表,则激活函数第 1 行的短语问题 1 Message: syntax error, unexpected '(', expecting ';' or '{' 工作正常

public function activate($id = 0){

}

问题 2 如果只使用($id = 0) Messege :'UPDATE Array SET mobile_no= '', voucher_amount= '11000', is_active= '1', updated_at= '2018-06-06 : 07:06:19', voucher_date= '2018-06-06 : 07:06 :19', voucher_no= '' 在哪里ci_usersid=“8”和voucherid='8'`

标签: phpdatabasecodeigniter-3

解决方案


推荐阅读