function savecompany_details($id)
{
$data[‘company_id’] = $id;
$this->db->insert(‘maint_company’, $data);
return $this->db->insert_id(); // <------ return the insert id (the id created when the record was inserted)
}
but, you are going to have a hard time getting one, with trying to insert a null record (unless every field in your database is set to allow null - other then the id which is auto incremented)