[英]Check whether update_batch() is successful in 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;
希望這可以幫助!。 干杯!
使用簡單的指令,這將返回true或false
return $this->db->update_batch("sections", $data, "alias");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.