Currently in my database I have a column called refno which has the format of LP-C-1024 where 1024 has to be an auto incrementing number while the LP-C- remains same. Now I want my query to reference the last record in my database and increment the number by +1 and have it so that when I include my insert statement, it should reference this value.
My current insert statement:
Controller Class:
$maindata=array('clients_id'=>$this->session->userdata('clientsessid'),
'agents_id'=>$this->security->xss_clean($this->input->post('agents_id')),
'refno'=>$this->security->xss_clean($this->input->post('refno')),
'title'=>$this->security->xss_clean($this->input->post('title'));
$insertid=$this->contacts_model->insert($maindata);
Model Class:
function insert($maindata)
{
$this->db->insert("crm_contacts",$maindata);
$prime=$this->db->insert_id();
return $prime;
}