从代码点火器中的插入模型获取响应

This is my controller

        $this->insert_model->form_insert($data);
        $data['message'] = 'Data Inserted Successfully';
        //Loading View
        $this->load->view('header');
        $this->load->view('post-add', $data);

This is my model

function form_insert($data){
    //Inserting in Table(students) of Database(college) 
    $this->db->insert('adds', $data); 
}    

data added to model (insert_model) and showd message - data insertd successfully

but i want to show message either SUCESS or error

Use $this->db->affected_rows(); to check data is insert or not

In Models

function form_insert($data) {
    //Inserting in Table(students) of Database(college) 
    $this->db->insert('adds', $data);
    $afftectedRows = $this->db->affected_rows();
    if ($afftectedRows > 0) {
        return TRUE;
    } else {
        return FALSE;
    }
}

In Controller

$insert = $this->insert_model->form_insert($data);
if ($insert) {
    $data['message'] = 'Data Inserted Successfully';
} else {
    $data['message'] = 'Error';
}
//Loading View
$this->load->view('header');
$this->load->view('post-add', $data);

Just make some changes in your code, like below:

Controller:-

if($this->insert_model->form_insert($data)){
    $data['message'] = 'Data Inserted Successfully';
}else{
    $data['message'] = 'Error message';
}
//Loading View
$this->load->view('header');
$this->load->view('post-add', $data);

Model :-

function form_insert($data){
   //Inserting in Table(students) of Database(college) 
   $this->db->insert('adds', $data);
   return $this->db->affected_rows();
}  

model

function form_insert($data){
    $this->db->insert('adds', $data);

    return $this->db->affected_rows() > 0;
}

Controller:

$this->insert_model->form_insert($data);
if (form_insert == true){
    $data['message'] = 'success';
} else {
    $data['message'] = 'error';
}
$this->load->view('header');
$this->load->view('post-add', $data);

We can get last inserted id. In Codeigniter, last inserted id returns by :

$this->db->insert_id();

I have tried below code & working fine for me.

<?php
            $is_insert=$this->insert_model->form_insert($data);
            if($is_insert > 0)
               $data['message'] = 'Data Inserted Successfully';
            else
               $data['message'] = 'Error in insert';
            //Loading View
            $this->load->view('header');
            $this->load->view('post-add', $data);


            function form_insert($data){
               //Inserting in Table(students) of Database(college) 
               $this->db->insert('adds', $data); 
               return $this->db->insert_id();
            }
        ?>

for CI reference please check below url: https://ellislab.com/codeigniter/user-guide/database/helpers.html