php – 检查update_batch()在CodeIgniter中是否成功

我在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;

希望这可以帮助!.干杯!

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...