diff options
author | Stanley Sufficool <ssufficool@php.net> | 2010-06-21 07:30:48 +0000 |
---|---|---|
committer | Stanley Sufficool <ssufficool@php.net> | 2010-06-21 07:30:48 +0000 |
commit | 7ea7787000b167b712a92115e0935386061c3749 (patch) | |
tree | c69890ed2d0515e235d0ffdd682974d7d74bdb42 /ext/pdo_dblib | |
parent | 5712b1ec9f80bc1ed883c0836f1d911e5d14c2ab (diff) | |
download | php-git-7ea7787000b167b712a92115e0935386061c3749.tar.gz |
Fix bug #38955 - add transaction support
Diffstat (limited to 'ext/pdo_dblib')
-rw-r--r-- | ext/pdo_dblib/dblib_driver.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 2b604db148..bf35951532 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -166,19 +166,53 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote return 1; } +static int pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC) +{ + pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; + RETCODE ret; + + if (FAIL == dbcmd(H->link, cmd)) { + return 0; + } + + if (FAIL == dbsqlexec(H->link)) { + return 0; + } + + return 1; +} + +static int dblib_handle_begin(pdo_dbh_t *dbh TSRMLS_DC) +{ + return pdo_dblib_transaction_cmd("BEGIN TRANSACTION", dbh TSRMLS_CC); +} + +static int dblib_handle_commit(pdo_dbh_t *dbh TSRMLS_DC) +{ + return pdo_dblib_transaction_cmd("COMMIT TRANSACTION", dbh TSRMLS_CC); +} + +static int dblib_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) +{ + return pdo_dblib_transaction_cmd("ROLLBACK TRANSACTION", dbh TSRMLS_CC); +} + static struct pdo_dbh_methods dblib_methods = { dblib_handle_closer, dblib_handle_preparer, dblib_handle_doer, dblib_handle_quoter, - NULL, - NULL, - NULL, - NULL, - NULL, /* last insert */ + dblib_handle_begin, /* begin */ + dblib_handle_commit, /* commit */ + dblib_handle_rollback, /* rollback */ + NULL, /*set attr */ + NULL, /* last insert id */ dblib_fetch_error, /* fetch error */ NULL, /* get attr */ NULL, /* check liveness */ + NULL, /* get driver methods */ + NULL, /* request shutdown */ + NULL /* in transaction */ }; static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC) |