CodeIgniter: affected_rows() and insert_id() usage

[php]
public function db_add_category()
{
$data = array(
"name"=>$this->input->post(‘addc_name’),
"parent"=>$this->input->post(‘addc_parent’)
);
$this->db->insert(‘categories’, $data);

if ($this->db->affected_rows()> 0)
return $this->db->insert_id();
else
return false;
}
[/php]