Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:19:33+00:00 2026-06-11T08:19:33+00:00

How much PHP code can / should I include within a single MySQL transaction?

  • 0

How much PHP code can / should I include within a single MySQL transaction? What is the best practice for transactions in terms of calling other classes & methods, manipulating or creating instances, etc, within a single transaction?

What I mean here by “include” is enter between beginTransaction(); and commit();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:19:35+00:00Added an answer on June 11, 2026 at 8:19 am

    I am used to use one transaction for one element and all its dependencies.

    For example, I have a forum where users can change their nickname. But they also can remove their account and I do not want to see posts removed. So I need to save somewhere in each post the name of my user in a VARCHAR or such.

    If a user changes his nickname, I will begin a transaction, changes his nickname everywhere it could be and if there were no errors, so I commit. I do not look at the number of requests at this point, because if one request fails I should be able to rollback everything regarding this change.

    But in a case that an admin changes 2 nicknames in an admin panel and validate once, I will open 2 transactions (one per user) to avoid having troubles with a single transaction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

there's nothing much to explain, i'll straight get to the sample code: <?php $array[0]['a']
Okay, so I've tried pretty much everything. $.post(include/ajax.php, { type: workbookNumber, wbn: $(input[name='wbn']).val() },
Getting this out of the way; I don't frequently do much in php or
I'm crawling a website using php. As I don't know much about turning php
I have a PHP script that very much like a commenting system, but requires
When I learned PHP it was pretty much in procedural form, more recently I've
I'm new to php world (actually not so much, but pretty much). I make
I'm newbie to PHP and I dont know much about database. I have one
In PHP, I know that mysql_real_escape is much safer than using addslashes . However,
Several times I heard that PHP hosting is much cheaper than ASP.NET one. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.