So what am I doing wrong? When I run the following code, the database is always updated even though transactions is in test mode.
/**
* update_batch
* This updates multiple rows. The data array must include the game_id and game_type_prize_id
* @param array
* @return bool
* @author zechdc
*/
function update_batch($data)
{
$result = TRUE;
foreach($data as $prize)
{
$this->db->trans_start(TRUE); //first param is set to TRUE for test mode.
$this->db->where('game_id', $prize['game_id']);
$this->db->where('game_type_prize_id', $prize['game_type_prize_id']);
$this->db->update('game_prizes', $prize);
$this->db->trans_complete();
if($this->db->affected_rows() == -1)
{
$result = FALSE;
}
}
return $result;
}
AbhishekDilliwal provided us with the answer in his comments. If he posts the answer I will delete mine and accept his so he gets credit instead of me.
Answer:
Codeigniter Transactions Test Mode Currently Does Not Work.
Solution:
Replace:
with:
in the following codeigniter system files:
It looks like rommelxcastro submitted the fix to the github repo already. Now we just have to wait for Codeigniter to pull it and release a new version 🙂
Sources: