我在CodeIgniter中的表上运行update_batch(),我想检查它是否成功.
我尝试过使用affected_rows(),但这只计算了已经修改过的表单字段的数量,因此它并没有完全删除它:
$this->db->update_batch("sections", $data, "alias");
log_message("debug", "items in form: ".count($data));
// items in form: 3
log_message("debug", "rows updated: ".$this->db->affected_rows());
// rows updated: 0-3
// depending on whether anything was actually changed on the form
return ($this->db->affected_rows() == count($data)); // unreliable
从批量更新功能中询问这似乎是一件相当简单的事情.有没有我错过的东西或者我应该编写自己的批量更新代码?
解决方法:
$this->db->trans_start();
$this->db->update_batch($table, $update, $variable);
$this->db->trans_complete();
return ($this->db->trans_status() === FALSE)? FALSE:TRUE;
希望这可以帮助!.干杯!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。