Home > Backend Development > PHP Tutorial > 请教php+mysql怎么实现写入数据成功全成功,失败全失败

请教php+mysql怎么实现写入数据成功全成功,失败全失败

WBOY
Release: 2016-06-13 12:57:48
Original
785 people have browsed it

请问php+mysql如何实现写入数据成功全成功,失败全失败?
比如我一次往数据库中写入10条数据,我想实现,如果全插入成功则提示成功,其中有一条失败的话,则全不要插入,请问该如何实现? 
------解决方案--------------------
需要用到数据库的事务,这个三言两语没法说清。不妨说说你的实际应用情况,附上一篇博文:http://www.gosoa.com.cn/php-mysql%E4%BA%8B%E5%8A%A1%E8%AF%A6%E8%A7%A3
------解决方案--------------------
需要事务回滚,可以看看thinkphp的事务操作,然后在自己原生代码写一下吧

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