I'm looking for a case how `transaction` do it's job. In first case I write a `sleep(10000)` between two queries, then turn of the wamp server:
PHP Code:
$this->db->trans_begin();
$q1 = $this->db->query("INSERT INTO `test`(`test_col`) VALUES ('aaaaaa')");
sleep(100000);
$q2 = $this->db->query("INSERT INTO `test`(`test_col`) VALUES ('bbbbbb')");
$this->db->trans_complete();
But first record is saved without second one. Then I tried with another case, that first query fails because of duplicated value:
PHP Code:
$this->db->trans_begin();
$q1 = $this->db->query("INSERT INTO `test`(`test_col`) VALUES ('duplicated')");
$q2 = $this->db->query("INSERT INTO `test`(`test_col`) VALUES ('new row')");
$this->db->trans_complete();
But again the new one exist in the database. Any idea? Is there anything I'm missing?
Also `trans_rollback` doesn't work.
PHP Code:
if ($this->db->trans_status() === FALSE)
{
// I get this line, but trans_rollback doesn't work
$this->db->trans_rollback();
}