codeigniter中的错误(数据未插入mysql数据库)

时间:2017-04-12 12:32:41

标签: codeigniter

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Employee extends CI_Controller {

public function _construct()
{
    parent::_construct();
    $this->load->model('employee_model');
    $this->load->helper(array('form','url'));
    }
    public function index()
    {
        $this->load->view('employee_form');
    }
    public function employee_form()
    {
    $save=array(
                'emp_name'  => $this->input->post('emp_name'),
                'emp_gender' => $this->input->post('emp_gender'),
                'emp_email'  => $this->input->post('emp_email'),
                'emp_phone'  => $this->input->post('emp_phone'),
                'emp_address'   => $this->input->post('emp_address')
               );
    $this->employee_model->saveemployee($save);
    redirect('employee/index');
    }   

}

这是我上面的代码并显示错误打击我在CodeIgniter中更新鲜我需要帮助

这是一个错误

enter image description here

3 个答案:

答案 0 :(得分:1)

Alway型号名称以大写字母开头。首先解决了这个问题。然后chek数据库设置

答案 1 :(得分:0)

您必须先加载数据库库。在

autoload.php:

$autoload[‘libraries’] = array(‘database’);

答案 2 :(得分:0)

public function _construct()
{
    parent::_construct();
    $this->load->model('employee_model');
    $this->load->helper(array('form','url'));
    private $employee_model = 'employee_model';
    }

首先在构造中设置它 然后,像这样称呼它

$this->{employee_model}->saveemployee($save);