mysql数据库更新和codeigniter行受影响的功能 [英] mysql database update and codeigniter rows affected function

查看:105
本文介绍了mysql数据库更新和codeigniter行受影响的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在更新查询后使用此函数此codeigniter函数

  $ this-> db-> affected_rows ; 

它返回受影响的行数,如果我更新值,但如果我更新的值与以前相同it retun 0 rows affected



任何帮助...

解决方案


是的,我知道我需要的是确认查询已成功运行。




$ b

  $ result = $ this-> db-> update('your_table',$ data); 
if(!$ result)
{
//错误
}
{
//函数ran ok - do whatever
}


I am using this function this codeigniter function after update query

$this->db->affected_rows();

it returns number of rows affected if i update values, but if i update values with the same as previous it retuns 0 rows affected

Any help...

解决方案

yes i understand what i need is the confirmation that query has successfully run.

All CI database functions return a result if they "successfully run".

So

$result = $this->db->update('your_table', $data);
if ( ! $result)
{
     // Error
}
{
     // Function ran ok - do whatever
}

这篇关于mysql数据库更新和codeigniter行受影响的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆