Giter Club home page Giter Club logo

Comments (8)

damianwadley avatar damianwadley commented on August 22, 2024 1

Ah, yes, that is true: have to stick to regular DDM statements during transactions, as DDLs need to make modifications that kinda break the ability to have a transaction going.

If you haven't seen it yet, there is a list of such DDL statements at https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html

from doc-en.

damianwadley avatar damianwadley commented on August 22, 2024

Everything I can see says the exact opposite: if you beginTransaction() and don't commit manually, it will be rolled back automatically. Not committed automatically, and certainly not that committing manually will error.

I assume you encountered this while working on some code of your own. Are you sure that there is an active transaction, as issued by beginTransaction or the equivalent BEGIN TRANSACTION statement, at the time of the call to commit()?

from doc-en.

Ome-Ko avatar Ome-Ko commented on August 22, 2024

Did some reading up and the issue is not with with autocommit but with MySQL implicit commits. I'm using the transaction for dropping and creating tables which result in ending the transaction. So the exception seems to be accurate indeed.

from doc-en.

Ome-Ko avatar Ome-Ko commented on August 22, 2024

Just saw that. Maybe mentioning this in the docs could safe some time for all parties involved. :-)
Thanks for helping out!

from doc-en.

damianwadley avatar damianwadley commented on August 22, 2024

It, uh, kinda already is mentioned...

https://www.php.net/manual/en/pdo.begintransaction.php

Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit COMMIT will prevent you from rolling back any other changes within the transaction boundary.

from doc-en.

Ome-Ko avatar Ome-Ko commented on August 22, 2024

Great. I never got beyond https://www.php.net/manual/en/pdo.transactions.php
:-)

from doc-en.

damianwadley avatar damianwadley commented on August 22, 2024

Funny, I was just thinking about that page...

If we have that about transactions and autocommits, it would make sense for details like "some statements may auto-commit a transaction" to be included there. After all, it's going through a lot of effort to talk about how transactions work, so what's another couple sentences?

I think that doing so would also mean it's not necessary for beginTransaction to have to talk about it. Or, for that matter, rollback (with the same statement) and commit (which, for some reason, instead has a note at the bottom).

All in all, it's worth giving a second thought.

from doc-en.

Ome-Ko avatar Ome-Ko commented on August 22, 2024

It got me fooled (but I'm as outdated as PHP 7 + easy to fool).

from doc-en.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.