Hey guys,
I have a quick question. Does EE provide a way to execute MYSQL transactions.
Now for something a little more specific…
I have two tables questions and answers. Each question has many answers. When an answer is added to the db so are multiple answers. When a question is destroyed so should the answers.
I want to make sure that there are no orphaned records when a question is created or updated.
Questions Table Cols - id - question
Answers Table Cols - id - question_id - answer
Any suggestions how I can secure this?
No, ExpressionEngine does not support transactions in the current 1.x branch via its built in Database class and methods. You can, of course, use the PHP functions for MySQL directly and do transactions yourself.
As for your question, does this really require transactions? MySQL only supports transactions in InnoDB database tables, which on host environments is not very common place, unless requested specficially.
No, ExpressionEngine does not support transactions in the current 1.x branch via its built in Database class and methods. You can, of course, use the PHP functions for MySQL directly and do transactions yourself. As for your question, does this really require transactions? MySQL only supports transactions in InnoDB database tables, which on host environments is not very common place, unless requested specficially.
No problem. I ended up creating a method for the question class called destory ($q = new Question; $q->destroy(); ) which destroys the question and all the child answers. When creating a new answer I check if it was created correctly and continue or destroy the question object.
There is only one place that some kind of transaction needed to be implemented and that solution works fine.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.