php - 更新两个表以生成发票和激活用户
问题描述
我需要在激活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_users
。id
=“8”和voucher
。id
='8'`
解决方案
推荐阅读
- javascript - 如何在没有错误的情况下安装反应应用程序
- c++ - 为什么这个模板总是被评估为 false_type?
- python - 稀疏分类交叉熵未按预期工作
- netlify - 如何在使用 Cecil 的 Netlify 上更改网站域名?
- sql - 包含多行的键上的火花合并(替换)
- php - 将部分分配给变量
- json - 不和谐重写如何让机器人在离开服务器时删除数据
- asp.net-core-webapi - Web api netcore 在 appsettings.json 文件中设置 Cors
- nginx - Nginx入口控制器路径重写不起作用
- c++11 - 在向量中查找继承的类对象 emplaced_back 的 unique_ptr