Skip to content

Commit 7ea7787

Browse files
author
Stanley Sufficool
committed
Fix bug #38955 - add transaction support
1 parent 5712b1e commit 7ea7787

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

ext/pdo_dblib/dblib_driver.c

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,53 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
166166
return 1;
167167
}
168168

169+
static int pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
170+
{
171+
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
172+
RETCODE ret;
173+
174+
if (FAIL == dbcmd(H->link, cmd)) {
175+
return 0;
176+
}
177+
178+
if (FAIL == dbsqlexec(H->link)) {
179+
return 0;
180+
}
181+
182+
return 1;
183+
}
184+
185+
static int dblib_handle_begin(pdo_dbh_t *dbh TSRMLS_DC)
186+
{
187+
return pdo_dblib_transaction_cmd("BEGIN TRANSACTION", dbh TSRMLS_CC);
188+
}
189+
190+
static int dblib_handle_commit(pdo_dbh_t *dbh TSRMLS_DC)
191+
{
192+
return pdo_dblib_transaction_cmd("COMMIT TRANSACTION", dbh TSRMLS_CC);
193+
}
194+
195+
static int dblib_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
196+
{
197+
return pdo_dblib_transaction_cmd("ROLLBACK TRANSACTION", dbh TSRMLS_CC);
198+
}
199+
169200
static struct pdo_dbh_methods dblib_methods = {
170201
dblib_handle_closer,
171202
dblib_handle_preparer,
172203
dblib_handle_doer,
173204
dblib_handle_quoter,
174-
NULL,
175-
NULL,
176-
NULL,
177-
NULL,
178-
NULL, /* last insert */
205+
dblib_handle_begin, /* begin */
206+
dblib_handle_commit, /* commit */
207+
dblib_handle_rollback, /* rollback */
208+
NULL, /*set attr */
209+
NULL, /* last insert id */
179210
dblib_fetch_error, /* fetch error */
180211
NULL, /* get attr */
181212
NULL, /* check liveness */
213+
NULL, /* get driver methods */
214+
NULL, /* request shutdown */
215+
NULL /* in transaction */
182216
};
183217

184218
static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC)

0 commit comments

Comments
 (0)