php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56340 Transactions not supported in PDO_ODBC
Submitted: 2005-03-05 16:27 UTC Modified: 2005-06-11 08:53 UTC
From: dbs@php.net Assigned: wez (profile)
Status: Closed Package: PDO_ODBC (PECL)
PHP Version: 5_1 CVS-2005-03-05 (dev) OS: Linux (RHEL 4)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dbs@php.net
New email:
PHP Version: OS:

 

 [2005-03-05 16:27 UTC] dbs@php.net
Description:
------------
PDO_ODBC, connecting to a DB2 database, does not support PDO::beginTransaction() / PDO::rollBack().

I tested the same code against both PDO_ODBC and PDO_SQLITE, but only PDO_SQLITE handled the rollback correctly

The required functionality for transaction management in PDO_ODBC should be available in the ODBC 3.0 SQLEndTran() function - see http://publib.boulder.ibm.com/infocenter/db2help/topic/com.ibm.db2.udb.doc/ad/r0000586.htm for more details.

Unit test pdo_017 has been added to the ext/pdo/tests and ext/pdo_odbc/tests branches to track this functionality.

Reproduce code:
---------------
<?php
$conn = new PDO('odbc:SAMPLE', 'db2inst1', 'ibmdb2');
//$conn = new PDO('sqlite:/home/daniels/bust');
$conn->exec('CREATE TABLE test (id INT)');
$conn->exec('INSERT INTO test(id) VALUES (1)');
$conn->exec('INSERT INTO test(id) VALUES (2)');
$conn->exec('INSERT INTO test(id) VALUES (3)');
$conn->beginTransaction();
function countRows($conn, $action) {
    $sql = "SELECT COUNT(*) FROM test";
    $stmt = $conn->query($sql);
    $num = $stmt->fetchSingle();
    return "Counted $num rows after $action.\n";
}
echo countRows($conn, 'insert');
$conn->exec('DELETE FROM test');
echo countRows($conn, 'delete');
$conn->rollBack();
echo countRows($conn, 'rollback');
?>


Expected result:
----------------
Counted 3 rows after insert.
Counted 0 rows after delete.
Counted 3 rows after rollback.

Actual result:
--------------
Counted 3 rows after insert.
Counted 0 rows after delete.
Counted 0 rows after rollback.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-10 02:24 UTC] wez@php.net
Is this still the case with latest CVS of PDO and PDO_ODBC?
 [2005-06-11 08:53 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Looks like the problem was that we weren't turning off auto-commit when a beginning a transaction.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC