4

I'm running update_batch() on a table in CodeIgniter and I'd like to check whether it was successful.

I've tried using affected_rows(), but that only counts the number of form fields that have been modified so it doesn't quite cut it:

$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

It seems like a fairly straightforward thing to ask from a batch update function. Is there something I've missed or should I just write my own batch update code?

4

2 回答 2

4
    $this->db->trans_start();
    $this->db->update_batch($table, $update, $variable);
    $this->db->trans_complete();        
    return ($this->db->trans_status() === FALSE)? FALSE:TRUE;

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

于 2013-07-25T11:35:22.643 回答
0

使用一个简单的指令,这将返回真或假

return $this->db->update_batch("sections", $data, "alias");
于 2012-05-02T12:26:21.627 回答