【发布时间】:2011-09-15 22:20:04
【问题描述】:
那我做错了什么?当我运行以下代码时,即使事务处于测试模式,数据库也会始终更新。
/**
* 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;
}
【问题讨论】:
标签: php codeigniter activerecord transactions