Note that there are some explanatory texts on larger screens.

plurals
  1. POPrevention of partial database operation
    primarykey
    data
    text
    <p>I made some functions in PHP which perform some or the other database operation like insertion, deletion, updating, etc. and I call the functions every time I want to do some operation.</p> <p>Now, lets say, I have the need to do the following:</p> <ul> <li>Call function 1 which does a Database operation, wait for the return message then</li> <li>Call function 2 which does another Database operation, wait for the return message then</li> <li>Call function 3 which does some other Database operation, wait for the return message</li> </ul> <p>If DB operation executed successfully in function1 and function2 but not in function3, then the complete operation is a failure since all three functions must be successful. In this case I would like to rollback the changes made by function1 and function2 since the operation is unsuccessful.</p> <p>I thought of stacking the queries and executing them all together at once but the problem is I don't know when I have to execute the query stack.</p> <p>eg. </p> <pre><code>if I call $obj-&gt;deletethread(); it calls $obj-&gt;deletemsg(); and $obj-&gt;deleteattachments(); and $obj-&gt;deletetags(); gets called </code></pre> <p>but this may not be the case all the time i.e.</p> <pre><code>if I call $obj-&gt;deletemsg(); $obj-&gt;deleteattachments(); and $obj-&gt;deletetags(); gets called </code></pre> <p>What I am trying to say is these functions can be called in any order by any other function. Is there any way to achieve this?</p> <p><strong>Why I need this:</strong> if a database operation is unsuccessful at any point, partial data is inserted in the tables where database operation was successful which I do not want since it will cause improper records.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload