我是MySQL的Codeigniter事务的新手。我的代码是
public function create_user($user_data, $customer_data, $company_data)
{
$this->db->trans_begin(); # Starting Transaction
# See Note 01. If you wish can remove as well
$res_id=$this->db->insert_id('customers', $customer_data); # Inserting data
error_log('RES-id');
error_log(strval($res_id));
$user_data['resource_id']=$res_id;
$this->db->insert('users', $user_data);
# Updating data
// $this->db->where('id', $id);
// $this->db->update('table_name', $test);
if ($this->db->trans_status() === FALSE) {
# Something went wrong.
$this->db->trans_rollback();
return FALSE;
}
else {
# Everything is Perfect.
# Committing data to the database.
$this->db->trans_commit();
return TRUE;
}
}
我正在错误记录一些东西以进行调试。因此,我正在进行事务处理,以首先获取自动递增的ID,然后将该ID插入到用户表中。但是它返回0,并且不会引发任何错误。我需要帮助。