Autocommit when die in class

From: Date: Wed, 17 Oct 2001 05:35:40 +0000
Subject: Autocommit when die in class
Groups: php.db 
Request: Send a blank email to php-db+get-13409@lists.php.net to get a copy of this message
I'm using php 4.0.4pl1 with oracle 8i. I have created a php class to handle data for a header table and another class to handle data for a details table. I have set to commit transaction only if both header and details are updated successfully. When a header record is inserted and the detail is failed. I issued a "die()" function in the detail class. The problem is that when the script die, the header record is automatic committed. Could someone tell me how to solve this problem ? Thank's. Leo ************************************************************* $conn = OCILogon(...); $header = new HeaderClass($conn); $detail = new DetailClass($conn); $header->Insert(...); for ($i=0; $i<n; $i++) { $detail->Insert(...); } OCICommit($conn); //-------------------------------------------------------------------------- - class HeaderClass { var $conn; function HeaderClass($c) { $this->conn = $c }; function Insert($vars) { $stmt = OCIParse($this->conn, sql); if (!OCIExecute($stmt, OCI_DEFAULT)) die("cannot insert to header"); } } class DetailClass { var $conn; function DetailClass($c) { $this->conn = $c }; function Insert($vars) { $stmt = OCIParse($this->conn, sql); if (!OCIExecute($stmt, OCI_DEFAULT)) die("cannot insert to detail"); } }

« previous php.db (#13409) next »