Home > Backend Development > PHP Tutorial > MySQL怎么确认update,delete,insert语句成功执行

MySQL怎么确认update,delete,insert语句成功执行

WBOY
Release: 2016-06-13 12:25:07
Original
1473 people have browsed it

MySQL如何确认update,delete,insert语句成功执行?
如题,现在一直通过mysql_affected_rows()在判断,这样的话就造成几乎每一句update,delete,insert后面必然要跟一句
if(mysql_affected_rows()!=1)
{
报错
}

请问有什么更简便的办法吗?
------解决思路----------------------
如果你不放心 update ... set money=money-1 会真实执行的话
那么你是否需要再 select 一下,确认 money 减少了 1,而不是减少了 100 呢?

$result = mysql_query("update ……")
只有在 sql 指令是错误的情况下,才会返回 false 
所以并不需要去试

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template