调用未定义的方法Employee :: insert_employee()

时间:2018-11-22 05:01:41

标签: codeigniter

控制器

         elseif ($param1 == 'add') {
                       $data['employee_deparatments'] = $this->department->get_departments($fldCompanyStringID);

        if ($this->input->post('viewType') == 'add' && $this->input->post('submit')) {
            $this->form_validation->set_rules('fldUserBranchName', 'Branch Name', 'required');

            if ($this->form_validation->run() == FALSE) {
                $this->session->set_flashdata('error_msg', validation_errors());
            } else {

                $this->employee->insert_employee($fldCompanyStringID);
            }
        }
    }

模型

class M_employee extends CI_Model {

    function get_employee ($fldCompanyStringID){
    }
}

2 个答案:

答案 0 :(得分:2)

您创建了一个文件名为<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <ul class="messages"></ul> <script> var text = 'Welcome to project, are you a here(1. new user one, 2. test user two, 3. minor Accident one or 4. Major Accident)'; var regex = /\((.*)\)/; var m; if ((m = regex.exec(text)) !== null) { console.log(m[1]); // 1. new user one, 2. test user two, 3. minor Accident one or 4. Major Accident var list = m[1]; var items = list.split(/([\d]. )/g); var message = $('.messages'); // Remove ' or ' from secondLastItem by removing the last 4 characters var secondLastItem = items[items.length-3]; items[items.length-3] = secondLastItem.substring(0, secondLastItem.length - 4); for(var i=1;i<items.length;i++) { // Ordered list // message.append('<li>' + items[++i].replace(', ', '') + '</li>'); // Unordered list message.append('<li>' + items[i] + items[++i].replace(', ', '') + '</li>'); } } // The intro text var introText = text.split('('); console.log(introText[0]); </script> 的模型,但在 controller 中,您称其为employee。

首先在 controller 中加载模型:

M_employee

接下来按此类型调用函数

$this->load->model('M_employee');

答案 1 :(得分:1)

您还可以为模型添加名称空间,ilke

First load the model in controller :

$ this-> load-> model('M_employee','employee');

接下来按此类型调用函数: $ this-> employee-> insert_employee($ fldCompanyStringID);

无需编辑控制器功能