作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Codeigniter 的新手,但从网络上学习,实际上我遇到了一个未知问题。
我将数据插入数据库抛出模型,然后将数据取回表单。
但是当我更新表单时,我想返回更新后的 ID。
我使用了 $user_id = $this->db->insert_id();
但这是为了获取插入 ID,
连我都试过了
$this->db->where('id_colum', $student_id);
$this->db->update('table_name', $data);
$user_id = $this->db->insert_id();
return $user_id;
帮帮我,感谢一切..
最佳答案
就像这样:
$this->db->where('id_colum', $student_id);
$this->db->update('table_name', $data);
$updated_status = $this->db->affected_rows();
if($updated_status):
return $student_id;
else:
return false;
endif;
如果已更新,则返回 $student_id。 :)
关于php - 如何在 codeigniter 中获取更新的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33330748/
我是一名优秀的程序员,十分优秀!