Comments (8)
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.
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.
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.
Just saw that. Maybe mentioning this in the docs could safe some time for all parties involved. :-)
Thanks for helping out!
from doc-en.
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.
Great. I never got beyond https://www.php.net/manual/en/pdo.transactions.php
:-)
from doc-en.
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.
It got me fooled (but I'm as outdated as PHP 7 + easy to fool).
from doc-en.
Related Issues (20)
- returns nothing instead of FALSE HOT 1
- List of functions is not in correct alphabetical order HOT 1
- rmdir clears cache
- ArrayIterator documentation is unclear HOT 3
- openssl_pkcs7_encrypt not work HOT 1
- function.array-column: Insufficient changelog HOT 1
- GearmanTask::jobHandle() can also return `false` HOT 3
- Misleading examples for strrchr() HOT 1
- PHP6407 HOT 1
- Performance Considerations - Reduced Memory Usage - Invalid PHP code in an example HOT 1
- UID10153 HOT 2
- mysqli_execute_query missing version information HOT 1
- I think what may be needed here is to add a note in UPGRADING that UTF-8 text handling now obeys the W3C specification, and this may result in different output for invalid UTF-8 strings.
- Classes - Example #17 Object name resolution HOT 2
- Option 'friendlyname' is wrong in openssl_pkcs12_export* HOT 1
- RecursiveDirectoryIterator misbehaves if the directory gets modified while iterating HOT 17
- Example #2 empty() on String Offsets
- Improve phrasing of the comments inside the code example #3.
- Incorrect return value section for enchant_broker_init()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doc-en.