2017-04-12 134 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);