I am using the Codeigniter framework but implemented a custom php pdo connection. The pdo is being loaded and initiated in MY_Model class which is being inherited by all my models.
The application is a blog and I have my models structured as follow:
Class Blog post Class Blog post url Class Blog post file Class Tag
In my db, there are 2 tables. one for blog post and one for blog post content (contains information for url, file, tag). The relationship between post and post content is one to many.
At the moment, when a new post is being submitted, class blog post will handle the validate/insert blog post information such as id, user and date. Then the url , tag, file classes will be loaded to validate/insert content information. As such, 4 PDO instances will be initiated, which causes problem as I would like to use PDO transaction to check all information are inserted correctly. Otherwise, no information will be inserted.as of now, it is hard to roll back the 4 instances.
Does anyone has a solution in resolving this issue?
Thanks.