Using transactions for single Insert/Update/Delete Statment?

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
User avatar
sudo-web
Joomla! Ace
Joomla! Ace
Posts: 1325
Joined: Fri Jan 22, 2016 7:10 pm
Location: Vienna - Austria
Contact:

Using transactions for single Insert/Update/Delete Statment?

Post by sudo-web » Sat Mar 17, 2018 3:42 pm

I was wondering if a single Insert/Update/Delete SQL Statement as mentioned in the Documentation has any benefit.

see: https://docs.joomla.org/Using_transactions_in_Joomla

Of course if you have more than one changing statement that makes perfect sense e.g.:
If you have to Insert/Update/Delete more than one table or have multiple,
statement that depend on each other, and the second Statement fails,the first will be reversed.

But what about the given example. What benefit or even disadvantage do I have if I use it just for one Insert/Update/Delete.
I assume this is only one transaction, so ether it fails during the $db->execute(); statement or not, right?

Is there any performance issue/loss if I use a transaction like so?
I assume so, because a tables get blocked till the transaction is commited, so others could edit it in the mean wile, right?

Thanks for clarification.
Visit me on my Webdesign Webpage: https://www.posit.at

Locked

Return to “Joomla! 3.x Coding”