[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.