2017-04-12 137 views
0
<?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'); 
    } 

} 

这是我上面的代码和错误显示的打击我在笨新鲜的,我需要帮助错误笨(数据在MySQL数据库中未插入)

这是一个错误

enter image description here

+0

请发表你的模型代码。 – kishor10d

+0

在codeigniter中,你不需要关闭控制器/模型/库的理由http://www.codeigniter.com/user_guide/general/styleguide.html#php-closing-tag – user4419336

回答

0

您必须先加载db库。在

autoload.php:

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

兄弟..我有之前做过 – deepak

1

送花儿给人的型号名称是大写字母开头。首先解决了这个问题。然后,赤数据库设置

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);