Are you familiar with the business or PDO? Always rollback, delete data solution

Source: Internet
Author: User
Are you familiar with the business or PDO? Always rollback, delete data
Database type: SQLite
No prompt error, one line test, there is no error, why always rollback? Always rollback, delete data
What do you suppose is the reason?
Here is the explanatory code:

PHP Code
  $king->db->connect ();  Connect the database $link a handle to the database connection. $king->db->link->begintransaction ();//Roll back the starting point if ($rs 1= $king->db->getrows_number ('%s_newscontent ', " NewsID in ($newsID))} {if ($rs 2= $king->db->query ("Delete from%s_newscontent where NewsID in ($newsID)")) {$ s.= "Delete news content successfully! [". $rs 2." /". $rs 1." Reviews
"; } else {lzj_message (' Delete news content failed ', ' Javascript:history.go (-1) '); }} if ($rs 1= $king->db->getrows_number ('%s_rss ', "idvalue in ($newsID) and tablename= ' News ' and Idname= ' NewsID '")) {if ($rs 2= $king->db->query ("Delete from%s_rss where tablename= ' news ' and Idname= ' NewsID ' and idvalue in ($newsI D)) {$s. = "Delete News RSS success!" [". $rs 2." /". $rs 1." Reviews
"; } else {lzj_message (' Delete news rss failed ', ' Javascript:history.go (-1) '); }} if ($rs = $king->db->query ("Delete from%s_news where NewsID in (". $newsID. ")") {lzj_message ("Delete succeeded! [". $rs." Reviews
". $s, $PAGEURL); } else {lzj_message (' Delete news failed ', ' Javascript:history.go (-1) '); } $king->db->link->commit ();//rollback end point


------Solution--------------------
I feel like you have a problem with this writing.
You can start things by setting up a logo such as flag=true;

if ($flag) {
Your operation .....
} else{
..............
$flag = false;
}
Continue with the next operation as above


At last
if ($flag) {
Submit Things
}else{

Rolling back
}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.