Hi there,
I'm currently facing a weird issue with an "old" CI (2.1.3).
Within the same method, I start a transaction, run some updates & inserts, commit the transaction and if everything is OK, I send an email.
It's been working for years, until today, without any code changes.
// Start the transaction
$this->db->trans_start();
// Do my updates & inserts
// Complete the transaction
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
// Return an error
} else {
// Send an email
}
Today's event : The email has been sent but without any inserts & updates done. I could see the queries being run. So, I assume it has rollbacked.
Three questions :
- Why can I have a trans_status to TRUE if it has rollbacked ? Am I missing something ?
- In Production, db_debug is at false, does it make any difference ? I was not able to see any logs, so I don't know where it has failed.
- How can I test a transaction failure ? I tried with using unknown table names. If db_debug is set to true, I get a 500. If db_debug is set to false, it goes all the way and returns a 200, BUT, the transaction is rollbacked and the trans_status is set to false. It works as expected