[eluser]xtremer360[/eluser]
I'm trying to figure out what would be the best route in handling the situation of what would happen if the title is created but then the second insert doesn't get ran successfully. What are some possibilities?
Code:
/**
* save_title function.
*
* @access public
* @param string $title_name
* @param string $title_directory_name
* @param integer $title_status_id
*
* @return TRUE/FALSE
* Should return title_id, title_name, title_directory_name, title_status_id
*/
public function save_title($title_name, $title_directory_name, $title_status_id)
{
$data = array(
'title_name' => $title_name,
'title_directory_name' => $title_directory_name,
'title_status_id' => $title_status_id
);
$this->db->insert('titles', $data);
if ($this->db->affected_rows() == 1)
{
$data = array(
'title_id' => $this->db->insert_id()
);
$this->db->insert('title_champions', $data);
if ($this->db->affected_rows() == 1)
{
return true;
}
else
{
return false;
}
}
}