Hi,
I've got an application which require multiple select, insert and update statements to complete a single transaction. As such, what would be the best way to code them?
If I'm going to do an if/else statement, it will be alot of repetitive code and nest ifs/elses.
Something like what you see at http://phpbuilder.com/columns/tim20010117.php3?page=2
But with more queries. Any good way to go about doing it?
I've read somewhere and the below is a good idea.
while (true) {
do query
check for errors
break if there's error
do query
check for errors
break if there's error
do query
check for errors
break if there's error
do query
check for errors
break if there's error
do query
check for errors
break if there's error
}
if (there is error) {
rollback
} else {
commit
}
This surely would prevent the code from swaying to the right and right and right again.. But still doesn't look elegant as it seems really repetitive..