怎么删除一条数据的同时将这条数据插入另一张表

WBOY
Release: 2016-06-13 10:08:58
Original
822 people have browsed it

如何删除一条数据的同时将这条数据插入另一张表
现在有两张表sns_topic,sns_topic_del,在sns_topic表的列表页进行编辑操作,要求删除一条数据的同时将这条数据插入sns_topic_del表,怎么做?

------解决方案--------------------
执行两条查询啊,先INSERT再DELETE,要确保数据一致性的话得用作为事务操作。
------解决方案--------------------
数据库中创建对应的触发器即可!
------解决方案--------------------

PHP code
mysql_query("START TRANSACTION");$sql1 = mysql_query('插入语句');$sql2 = mysql_query('删除语句');if($sql1 && $sql2){//提交      mysql_query('COMMIT');}else{//事务回滚      mysql_query('ROLLBACK');}mysql_query('END');<div class="clear">
                 
              
              
        
            </div>
Copy after login
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