Skip to content

Instantly share code, notes, and snippets.

@novasky-zz
Last active August 29, 2015 14:05
Show Gist options
  • Save novasky-zz/772e09e2329be73f9c8d to your computer and use it in GitHub Desktop.
Save novasky-zz/772e09e2329be73f9c8d to your computer and use it in GitHub Desktop.
Fixed: Rollback transactions in PHP ADODB
<?php
/*
* Problem: RollbackTrans() command doesn't work
*
* FIX:
* The problem happens whenever I use the "mysql" driver to connect in the database
* To fix it, I used the "mysqli" driver in ADODB Connection
*
* The next example is the correct use of Transactions in ADODB
*/
$DB = &ADONewConnection("mysqli");
$DB->Connect('hostname', 'db_user', 'db_pass', 'db_name');
$DB->BeginTrans();
$DB->Execute(" SQL QUERY ");
$DB->Execute(" SQL QUERY ");
// Revert all SQL queries:
$DB->RollbackTrans();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment