Bug #13986 Updated: Cannot rollback transaction when die in class
| From: | sniper@php.net | Date: | Fri, 09 Nov 2001 14:41:58 +0000 |
| Subject: | Bug #13986 Updated: Cannot rollback transaction when die in class | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-69878@lists.php.net to get a copy of this message | ||
ID: 13986
Updated by: sniper
Reported By: leo_ngsungchun@sinaman.com
Old Status: Open
Status: Feedback
Bug Type: Class/Object related
Operating System: Win2k / Linux + Oracle8i+Apache
PHP Version: 4.0.4pl1
New Comment:
Have you tried PHP 4.0.6 ?
Previous Comments:
------------------------------------------------------------------------
[2001-11-08 01:47:35] leo_ngsungchun@sinaman.com
I am using a database class to manipulate data.
I found that when the program is terminated in
the class, the transaction will be committed,
even I've set the mode to OCI_DEFAULT.
The same case occured in both Win2k and Linux with
Oracle and Apache.
////////////////////////////////////////////////
// Schema
////////////////////////////////////////////////
/*
create table test (
id varchar2(5) not null,
name varchar2(10),
primary key (id)
);
////////////////////////////////////////////////
// Source Code
///////////////////////////////////////////////
class Database {
var $conn, $stmt, $row_data;
function Database()
{
$DB_SERVER = "";
$DATABASE = "";
$DB_USER = "test";
$DB_PASSWORD = "test";
putenv($DATABASE);
$this->conn = OCILogon($DB_USER, $DB_PASSWORD, $DB_SERVER);
if ($this->conn == false) {
die("Cannot connect to server");
}
}
function Query($sql)
{
$this->stmt = OCIParse($this->conn, $sql);
if ($this->stmt == false) {
die("Statement Error");
}
if (OCIExecute($this->stmt, OCI_DEFAULT) == false) {
die("Cannot Execute Statment");
}
}
function Commit()
{
OCICommit($this->conn);
}
function terminate()
{
die(" Not OK :( ");
}
}
$db = new Database();
$sql = "insert into test (id, name) values ('1', '1')";
$db->Query($sql);
$db->terminate(); // This will commit the transaction,
// even the program is terminated.
die(" OK :) "); // If the program is terminated here,
// the transaction is rollbacked.
$db->Commit();
------------------------------------------------------------------------
[2001-11-08 01:42:41] leo_ngsungchun@sinaman.com
I am using a database class to manipulate data.
I found that when the problem is terminated in
the class, the transaction will be committed,
even I've set the mode to OCI_DEFAULT.
The same case occured in both Win2k and Linux with
Oracle and Apache.
////////////////////////////////////////////////
// Schema
////////////////////////////////////////////////
/*
create table test (
id varchar2(5) not null,
name varchar2(10),
primary key (id)
);
////////////////////////////////////////////////
// Source Code
///////////////////////////////////////////////
class Database {
var $conn, $stmt, $row_data;
function Database()
{
$DB_SERVER = "";
$DATABASE = "";
$DB_USER = "test";
$DB_PASSWORD = "test";
putenv($DATABASE);
$this->conn = OCILogon($DB_USER, $DB_PASSWORD, $DB_SERVER);
if ($this->conn == false) {
die("Cannot connect to server");
}
}
function Query($sql)
{
$this->stmt = OCIParse($this->conn, $sql);
if ($this->stmt == false) {
die("Statement Error");
}
if (OCIExecute($this->stmt, OCI_DEFAULT) == false) {
die("Cannot Execute Statment");
}
}
function Commit()
{
OCICommit($this->conn);
}
function terminate()
{
die(" Not OK :( ");
}
}
$db = new Database();
$sql = "insert into test (id, name) values ('1', '1')";
$db->Query($sql);
$db->terminate(); // This will commit the transaction,
// even the program is terminated.
die(" OK :) "); // If the program is terminated here,
// the transaction is rollbacked.
$db->Commit();
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=13986&edit=1