From: Stanley Sufficool Date: Mon, 21 Jun 2010 07:30:48 +0000 (+0000) Subject: Fix bug #38955 - add transaction support X-Git-Tag: php-5.4.0alpha1~191^2~1261 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ea7787000b167b712a92115e0935386061c3749;p=php Fix bug #38955 - add transaction support --- 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)