为了账号安全,请及时绑定邮箱和手机立即绑定

尝试更新 2 个表中的数据

尝试更新 2 个表中的数据

PHP
江户川乱折腾 2022-06-17 15:45:59
这是代码:  if ($param1 == 'do_update') {            $data['student_id']         = $this->input->post('student_id');            $data['title']              = html_escape($this->input->post('title'));            if ($this->input->post('description') != null) {                $data['description']        = html_escape($this->input->post('description'));            }            $data['amount']             = html_escape($this->input->post('amount'));            $data['amount_paid']        = html_escape($this->input->post('amount_paid'));            $data2['amount']            = html_escape($this->input->post('amount'));            /*$data['status']             = $this->input->post('status');*/            $data['creation_timestamp'] = strtotime($this->input->post('date'));            $this->db->where('invoice_id', $param2);            $this->db->update('invoice', $data);            $this->db->where('invoice_id', $param2);            $this->db->update('payment', $data2);2 表发票和付款...我可以使用特定 ID 更新“发票表”中的数据,但同时,它正在更新“付款表”中的整个列而不是该特定 ID。我可以看出在最后 4 行中做错了什么。$data 字段属于 Invoice 表,$data2 字段属于 Payment 表Invoice_id 在两个表中都很常见..
查看完整描述

1 回答

?
人到中年有点甜

TA贡献1895条经验 获得超7个赞

你实际上并没有使用你的 where 条件。尝试:

$this->db->where('invoice_id', $param2)->update('invoice', $data);
$this->db->where('invoice_id', $param2)->update('payment', $data2);


查看完整回答
反对 回复 2022-06-17
  • 1 回答
  • 0 关注
  • 110 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号