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 7900423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:58:01+00:00 2026-06-03T08:58:01+00:00

I have just successfully attempted using beginTransaction() to execute my sql statements in my

  • 0

I have just successfully attempted using beginTransaction() to execute my sql statements in my project using PHP. I have an array of items need to be written to the database, and each item must be validated against something before getting stored. One of the good things about turning off the auto-commit behaviour of a database is you can rollback the whole transaction if something goes wrong in the middle. In my project, if one item is invalid, the whole array should not be recorded in the database, which is why I chose to use this approach.

Now I am just wondering if this really is a better way in terms of performance? Because even if the last item in the array is validated, I still need to manually commit() the previous execution. Does commit repeat the sql execution?

The only advantage I can think of right now is you only need to do one loop instead of two if you want to validate them all (assuming all items are valid) and then write each of them.

  • 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-03T08:58:03+00:00Added an answer on June 3, 2026 at 8:58 am

    Commit does not repeat SQL execution.

    Typically, when working in a transactional, whenever you execute an INSERT/UPDATE/DELETE statement, the database takes a copy of the records/data pages to a transaction log, and then executes the actual record changes.

    If anybody else tries to access those records/data pages during the course of your transaction, they will be redirected to the copy in the transaction log.

    Then, when you execute the commit, the data in the database itself is already updated, and all the server needs to do is delete the transaction log.

    If you rollback rather than commit, then the database server backtracks through the transaction log, restoring all the records/data pages that you have updated to their original state, deleting each transaction log entry as it goes.

    Therefore, a rollback is an overhead, because the database server has to restore the data to its pre-transaction state.

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

Sidebar

Related Questions

I have just successfully installed CakePHP and I see that I can edit the
We have just completed implementing a successful but problematic project. We want to get
I have just created a report in Report Manager using a Stored Procedure which
I have just begun working on a project which uses Mercurial as a version
I have created a web application using Jersey and Dynamic Web Project of Eclipse.
I have successfully built a thin client/server using Qt's Tcp Sockets API. I know
I have a SQL Server 2005 named instance using Windows Authentication with domain groups
I just start using Mercurial yesterday (I don't have much programming experiences). I noticed,
Using the examples from the CGI::Session::Auth::DBI and CGI::Session::Auth pages, I have attempted to implement
I have just started reading Modern C++ Design Generic programming and Design Patterns Applied

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.