I have an active record style insert query which has been used to insert the form fields into a MySQL table. I want to get the last auto-incremented id for the insert operation as the return value of my query but have been facing issues with it. Have shared my code below:-
Inside the controller:
function add_post(){ 
        $post_data = array( 
              'id' => '', 
              'user_id' => '11330', 
              'content' => $this->input->post('poster_textarea'), 
              'date_time' => date("Y-m-d H:i:s"), 
              'status' => '1' 
    ); 
    return $this->blog_model->add_post($post_data); 
}
Inside model:
function add_post($post_data){ 
        $this->db->trans_start(); 
        $this->db->insert('posts',$post_data); 
        $this->db->trans_complete(); 
        return $this->db->insert_id(); 
}
I get nothing as the return of the add_post in the model. Could anyone please help me with this?