Welcome Guest, Not a member yet? Register   Sign In
oracle database driver has bug on query() which fails trans_start() trans_complete()
#1

[eluser]Unknown[/eluser]
Hi,
Just got this bug. Normally working with ORACLE using trans_start() and trans_complete()
would prevent any incomplete transaction to be autocommited.
Yes this is true, but if the transaction has to use query() instead of simple_query()
in the middle of the transaction then problem comes to rise.
/* a working transaction */
$this->db->trans_start(TRUE);
$this->db->simple_query("insert into test
(id,name)
values
('1','ade1') ");
$this->db->simple_query("insert into test
(id,name)
values
('1','ade2') ");
$this->db->simple_query("insert into test
(id,name)
values
('1','ade3') ");
$this->db->trans_complete();

Expected result:
rollback

Actual result:
rollback

/* a not working transaction */
$this->db->trans_start(TRUE);
$this->db->simple_query("insert into test
(id,name)
values
('1','ade1') ");
$this->db->simple_query("insert into test
(id,name)
values
('1','ade2') ");
$result = $this->db->query("select * from test");
$this->db->simple_query("insert into test
(id,name)
values
('1','ade3') ");
$this->db->trans_complete();

Expected result:
rollback

Actual result:
2 rows inserted

Solution:
modified system/database/driver/oci8/oci8_result.php at line 46 and 50.
@ociexecute($this->stmt_id);
become
@ociexecute($this->stmt_id, OCI_DEFAULT);

Since ociexecute() is
bool oci_execute ( resource $statement [, int $mode = OCI_COMMIT_ON_SUCCESS ] )
We do not want the $ROW->num_rows() commit our transaction.

Hope it helps.
#2

[eluser]Unknown[/eluser]
thanks a lot you saved me hours Smile




Theme © iAndrew 2016 - Forum software by © MyBB