php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58600 Support for transactions -mssql
Submitted: 2009-03-27 04:57 UTC Modified: 2011-12-01 05:38 UTC
From: sigurdne at online dot no Assigned: ssufficool (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.6 OS: Ubuntu 8.10
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: sigurdne at online dot no
New email:
PHP Version: OS:

 

 [2009-03-27 04:57 UTC] sigurdne at online dot no
Description:
------------
Would be nice to support transactions for mssql.

Tried both the precompiled ubuntu packages and custom built from pecl with the same result:

'This driver doesn't support transactions'

Cutom built:
versions:
* PDO-1.0.3
* PDO_DBLIB-1.0
* FreeTDS 0.82

To allow configure to work:
 $ touch /usr/include/tds.h
 $ touch /usr/lib/libtds.a

configure:
 $ ./configure --with-mssql


Reproduce code:
---------------
$this->db = new PDO("dblib:host={$this->Host};dbname={$this->Database}", $this->User, $this->Password, array(PDO::ATTR_PERSISTENT => $persistent));

$this->db->beginTransaction();

Actual result:
--------------
Error message: 'This driver doesn't support transactions'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-30 02:26 UTC] sigurdne at online dot no
By looking at the pdo_mysql - it looks like something like this could work.
However there seems to be a problem that the transaction state is not reported correctly - so when it comes to the commit - it claims that it is not in a transaction.

Anyone that could help out?

diff -aburN --exclude='.svn*' --exclude='CVS*' PDO_DBLIB-1.0.org/dblib_driver.c PDO_DBLIB-1.0/dblib_driver.c
--- PDO_DBLIB-1.0.org/dblib_driver.c	2005-10-16 16:58:50.000000000 +0200
+++ PDO_DBLIB-1.0/dblib_driver.c	2009-03-27 13:10:14.000000000 +0100
@@ -166,14 +166,30 @@
 	return 1;
 }
 
+static int dblib_handle_begin(pdo_dbh_t *dbh TSRMLS_DC)
+{
+	return 0 <= dblib_handle_doer(dbh, ZEND_STRL("BEGIN TRAN") TSRMLS_CC);
+}
+
+static int dblib_handle_commit(pdo_dbh_t *dbh TSRMLS_DC)
+{
+	return 0 <= dblib_handle_doer(dbh, ZEND_STRL("COMMIT TRAN") TSRMLS_CC);
+}
+
+static int dblib_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
+{
+	return 0 <= dblib_handle_doer(dbh, ZEND_STRL("ROLLBACK TRAN") TSRMLS_CC);
+}
+
+
 static struct pdo_dbh_methods dblib_methods = {
 	dblib_handle_closer,
 	dblib_handle_preparer,
 	dblib_handle_doer,
 	dblib_handle_quoter,
-	NULL,
-	NULL,
-	NULL,
+	dblib_handle_begin,
+	dblib_handle_commit,
+	dblib_handle_rollback,
 	NULL,
 	NULL, /* last insert */
 	dblib_fetch_error, /* fetch error */
 [2011-12-01 05:38 UTC] ssufficool@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Try 5.4 RC2
 [2011-12-01 05:38 UTC] ssufficool@php.net
-Status: Open +Status: Closed -Package: PDO_DBLIB +Package: *General Issues -Assigned To: +Assigned To: ssufficool
 [2012-03-10 17:36 UTC] programmer at finner dot de
This issue is identical to #38955 (from 2006-09-25!!!). Obviously nobody 
recognized, that the OP referred to MSSQL via DBLIB/FreeTds, NOT to MySQL. I did 
not find anything about issues #38955 or #58600, or anything about a fix of lack 
of transactions in the changelogs up to 5.4, and with 5.3.10 I got this error 
myself today. Therefore, this issue should remain open until it is really fixed. 
Issue #38955 is also closed due to "No developer cares about it", which is quite 
arrogant.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 30 13:00:02 2025 UTC