php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65979 Commit example and transactions
Submitted: 2013-10-28 01:38 UTC Modified: 2013-12-31 19:37 UTC
From: kbcmdba at gmail dot com Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: 5.5Git-2013-10-28 (Git) OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kbcmdba at gmail dot com
New email:
PHP Version: OS:

 

 [2013-10-28 01:38 UTC] kbcmdba at gmail dot com
Description:
------------
I don't understand why documenters chose to use autocommit(FALSE) to "start" a transaction rather than begin_transaction(). In fact, turning off autocommit doesn't start a transaction at all in environments where autocommit is off by default (depends on how the DBA configured MySQL). The example would be wiser / safer if it had shown users that it's safer to explicitly start a transaction while possibly turning autocommit off.

http://dev.mysql.com/doc/refman/5.0/en/commit.html describes the behavior of START TRANSACTION, COMMIT and ROLLBACK.

Note that DBAs can turn off autocommit by default setting the autocommit or the init_connect variables in my.cnf/my.ini. In fact, I tell my developers not to assume that autocommit is on or off. I encourage developers to set it the way they want it for their application's needs in their application's DAL setup. That way, assuming it's "the other way" can't come back to bite you. :-)

---
From manual page: http://www.php.net/mysqli.commit
---



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-31 19:37 UTC] frozenfire@php.net
-Status: Open +Status: Wont fix
 [2013-12-31 19:37 UTC] frozenfire@php.net
I'm not sure that the documentation needs to be changed in any way. The example code that is currently present in the documentation isn't *wrong* - it's just not in line with your way of doing things.

I agree that one shouldn't ordinarily rely upon autocommit being turned off, but the purpose of the documentation example is purely to demonstrate the invocation of the commit method.

Demonstrating how to initiate a transaction just so as to demonstrate how to use the commit method would require unnecessary added code.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 14:01:32 2024 UTC