How to run Transactions in controller? |
04-02-2021, 10:08 PM
(This post was last modified: 04-03-2021, 05:20 AM by yahyaerturan. Edit Reason: Use coding block this time. ) (04-02-2021, 06:01 AM)InsiteFX Wrote: Transactions should be handled in the Model that's where your business logic should be. I am not sure if it is the best practice but if not I want to learn the correct way ![]() I think it should be handled in controller for the following reasons: - In a controller endpoint it can be used methods from different models which we want all to be in same transaction. For example, adding new tags to article when adding a new article, or adding new product tags when adding a new product. - Sending response from API endpoint if transaction fails. Here is an example how I use it: PHP Code: /** If there is a better way, I'd like to learn.. |
Messages In This Thread |
How to run Transactions in controller? - by webdevron - 04-02-2021, 05:21 AM
RE: How to run Transactions in controller? - by InsiteFX - 04-02-2021, 06:01 AM
RE: How to run Transactions in controller? - by yahyaerturan - 04-02-2021, 10:08 PM
RE: How to run Transactions in controller? - by mlurie - 04-06-2021, 09:44 AM
RE: How to run Transactions in controller? - by mlurie - 01-09-2023, 07:35 AM
|