Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Possible use of mysql rollback?

Questions related to using nuBuilder Forte.
Post Reply
slobodan
Posts: 25
Joined: Sat May 08, 2021 1:20 pm

Possible use of mysql rollback?

Unread post by slobodan »

Is it possible to rollback last save(update), using AS(after save) php code?
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Possible use of mysql rollback?

Unread post by kev1n »

Can't you use the BS event to prevent the saving in the first place?

To rollback a saving operation you'd have to retrieve the values that are stored in the table in BS, store their values in a session variable and then UPDATE your record with the old values in AS.
slobodan
Posts: 25
Joined: Sat May 08, 2021 1:20 pm

Re: Possible use of mysql rollback?

Unread post by slobodan »

The idea is to consistently perform all related updates on the database or, if any of that gets stuck, to restore the database to its previous state. If this cannot be done in the same dbase transaction, the closest option is your suggestion. So, if mysql saved procedure started in AS, did rollback, data that was updated by the form, should be returned to the state stored in BS. Is it correct?
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Possible use of mysql rollback?

Unread post by kev1n »

slobodan wrote: or, if any of that gets stuck, to restore the database to its previous state.
Either all data is saved or none. In which scenario would data not be fully stored ?
slobodan wrote: So, if mysql saved procedure started in AS, did rollback, data that was updated by the form, should be returned to the state stored in BS. Is it correct?
yes
slobodan
Posts: 25
Joined: Sat May 08, 2021 1:20 pm

Re: Possible use of mysql rollback?

Unread post by slobodan »

I used to work on an application for a manufacturing company, where dynamic part reservations were done in warehouses. On the principle of competition, where it was necessary to maintain the synchronized conditions in several accompanying tables. This was done strictly in database transactions, in order to maintain the consistency of the data. Most forms do not require such complex processing, but it is better to make an effort to learn new software, if it allows such things.
It seems to me that nuBuilder is worth the effort, although online sources of information are much rarer than for some others, such as for Oracle APEX for example. In that sense, thank you for your quick answers on this forum.

Slobodan
Post Reply