|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 10:00:02 2025 UTC |
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 */