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

  • Home
  • SEARCH
  • 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 8035807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:25:15+00:00 2026-06-05T02:25:15+00:00

In straight mysql script I’d do transactions like this: START TRANSACTION; SELECT @A:=SUM(salary) FROM

  • 0

In straight mysql script I’d do transactions like this:

START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;

i’m a little confused about how transactions work in PDO. It looks like there are beginTransaction() and commit() methods – so I’m not sure are these just convenience wrappers around staright SQL? or are they doing some more job behind the doors?

In other words – are these examples below essentially the same?

example 1:

$dbh->exec( 'START TRANSACTION' );
//...do some db work here...
$dbh->exec( "COMMIT" );

example 2:

$dbh->beginTransaction();
//...do some db work here...
$dbh->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-05T02:25:17+00:00Added an answer on June 5, 2026 at 2:25 am

    Functionality wise both are same, but beginTransaction() and commit() are PDO functions which ensures compatibility with all database and there might be some database which may give error at START TRANSACTION but the PDO methods will always work.

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

Sidebar

Related Questions

I have the following MySql query: select t1.* from Table1 t1 inner join Table2
I wonder if this is possible with straight SQL on MySQL. I need to
mysql> EXPLAIN SELECT * FROM urls ORDER BY RAND() LIMIT 1; +----+-------------+-------+------+---------------+------+---------+------+-------+---------------------------------+ | id
My problem is rather straight-forward: Retrieve an image from a MySQL database (currently stored
So this should be a fairly straight forward trigger, but my MySQL isn't great,
I've googled this but can't get a straight answer. I have a mysql database
could someone help me out? I have done a straight forward MySQL query from
This should be relatively straight forward however I'm being swamped in SQL information whenever
Is there a straight-forward way in SQL syntax to write this in a single
This should be very straight forward, but even looking at the other questions, 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.