We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

MYSQL Transactions - Are they possible

Development and Programming

Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

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?

       
Paul Burdick's avatar
Paul Burdick
480 posts
17 years ago
Paul Burdick's avatar Paul Burdick

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.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham
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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.