I am not seeing methods in the Model class to allow for transactions and I am wanting to avoid changing anything inside the engine folder.
What is the best way for me to implement PDO transactions without editing the Model class?
Should I extend the Model class in my module and use that?
Would that result in multiple open connections to the database?
Would that be a bad thing?
Would it be safe enough for me to add public methods to the end of the Model class for begin_transaction() , rollback(), and commit(), and when updating Trongate I can just make sure I add those methods back in?
Are there methods in Model that would not be suitable for using while a transaction was active?
I am not a professional developer so there is so much I don't know.
Thank you for your guidance!
How to use database transaction with Trongate?
3 years ago
3 years ago
#1
3 years ago
#2
For now I added this to Model
When I introduce an error during the transaction it performs the rollback as expected.
I am using only two Model methods Model::insert and Model::insert_batch during the transactions.
Assuming this is the best way to proceed, should I be testing that I am actually in a transaction before commit and rollback?
When I introduce an error during the transaction it performs the rollback as expected.
I am using only two Model methods Model::insert and Model::insert_batch during the transactions.
Assuming this is the best way to proceed, should I be testing that I am actually in a transaction before commit and rollback?