note 44960 added to function.odbc-autocommit

From: Date: Sat, 21 Aug 2004 06:51:16 +0000
Subject: note 44960 added to function.odbc-autocommit
Groups: php.notes 
Request: Send a blank email to php-notes+get-75042@lists.php.net to get a copy of this message
using autocommit functionality to rollback transactions in a "workspace" <?php $conn = odbc_connection("$DSN","USER","PASS"); //turns off autocommit odbc_autocommit($conn,FALSE); $query1 = "some SQL"; $query2 = "some more SQL"; $ErrorCount = 0; //if odbc_exec fails it will increment the $ErrorCount $result = odbc_exec($conn,$query1) or $ErrorCount++; $result2 = odbc_exec($conn,$query2) or $ErrorCount++; //checking for errors, commit if none, rollback else if ($Errorcount == 0){ odbc_commit($conn); echo "transaction successful"; } else{ odbc_rollback($conn); echo "there were errors processing the transaction. No changes were made to the database"; } odbc_close($conn); ?> Cheers, Ron ---- Manual Page -- http://www.php.net/manual/en/function.odbc-autocommit.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44960 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44960&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44960&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75042) next »