我在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;
希望这可以帮助!.干杯!