Making a multiple different editor instances be one singular transaction
Making a multiple different editor instances be one singular transaction
Hello there, I'm currently working on a system where I have the user create a new entry via one editor, and then immediately create the quantity child entries that they set in the initial editor. This is important because each cild entry has different data tied to and must be set on creation by the user.
I was wondering if there was a way to make all of this process one seamless transaction with my database, so that if the user decides to exit the child editor mid adding, the parent element and other already filled out child elements are rolled back to avoid data errors.
Thank you!
Answers
You should be able to do this using Editor's database methods. There is some documentation on them, but I couldn't find it right now. You would need to search in the Editor PHP files, I guess.
How would I do it?
- I would first turn off autocommit using Editor's db-handler
- Then I would call beginTransaction()
- Depending on the outcome of the user's work I would either
- commit() the changes or
- rollBack() the changes
- finally I would turn autocommit back on.
These are the methods my own db handler is providing for this. You would need to find Editor's methods though.
And here is something from the Editor docs. Good luck!
https://editor.datatables.net/docs/2.3.2/php/classes/DataTables-Database-Query.html