本文介绍了检查update_batch()是否成功在codeIgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我跑update_batch()上表中codeIgniter,我想看看它是否成功。
我已经使用affected_rows()试过了,但仅计算已被修改,因此它不会很削减它的表单字段数量:
$这个 - > DB-> update_batch(节,$数据,别名); log_message(调试,形式的项目:.Count之间($数据)); //形式的项目:3 log_message(调试,更新的行:$这个 - > DB-> affected_rows()); //行更新时间:0-3 //这取决于什么是否真的改变了形式 返回($这个 - > DB-> affected_rows()==计数($数据)); //不可靠
这似乎是一个相当简单的事情要问从批量更新功能。有什么我已经错过了或者我应该只写我自己的批量更新code?
解决方案 $这个 - > DB-> trans_start(); $这个 - > DB-> update_batch($表,$更新,$变量); $这个 - > DB-> trans_complete(); 返回($这个 - > DB-> trans_status()=== FALSE)? FALSE:TRUE;
希望这有助于!干杯!
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)); // unreliableIt 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?
解决方案 $this->db->trans_start(); $this->db->update_batch($table, $update, $variable); $this->db->trans_complete(); return ($this->db->trans_status() === FALSE)? FALSE:TRUE;Hope this helps!. Cheers!
更多推荐
检查update
发布评论