检查update

编程入门 行业动态 更新时间:2024-10-27 18:28:08
本文介绍了检查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)); // 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?

解决方案

$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

本文发布于:2023-11-07 15:03:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566768.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:update

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!