我试图找出处理如果创建用户但第二次插入没有成功运行会发生什么情况的最佳途径。有哪些可能性?
/**
* save_user function.
*
* @access public
* @param string $user_name
* @param string $user_directory_name
* @param integer $user_status_id
*
* @return TRUE/FALSE
*/
public function save_user($user_name, $user_directory_name, $user_status_id)
{
$data = array(
'user_name' => $user_name,
'user_directory_name' => $user_directory_name,
'user_status_id' => $user_status_id
);
$this->db->insert('users', $data);
if ($this->db->affected_rows() == 1)
{
$data = array(
'user_id' => $this->db->insert_id()
);
$this->db->insert('user_profiles', $data);
if ($this->db->affected_rows() == 1)
{
return true;
}
else
{
return false;
}
}
}