gpt4 book ai didi

php - 在CodeIgniter中查看update_batch()是否成功

转载 作者:可可西里 更新时间:2023-10-31 23:08:37 28 4
gpt4 key购买 nike

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

希望这对您有所帮助!干杯!

关于php - 在CodeIgniter中查看update_batch()是否成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10398907/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com