需要测试SQL查询是否成功 [英] need to test if sql query was successful
本文介绍了需要测试SQL查询是否成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个查询,如果返回成功,我希望另一个函数可以处理,否则请不要处理该函数.
I have this query and if it returns successful, I want another function to process, if not, do not process that function.
这是运行查询的代码
global $DB;
$DB->query("UPDATE exp_members SET group_id = '$group_id' WHERE member_id = '$member_id'");
我想这就像...
if($DB) {
//success
} else {
//failure
}
推荐答案
这是您测试的最简单方法
This is the simplest way you could test
$query = $DB->query("UPDATE exp_members SET group_id = '$group_id' WHERE member_id = '$member_id'");
if($query) // will return true if succefull else it will return false
{
// code here
}
这篇关于需要测试SQL查询是否成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文