Reputation: 1
<?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');
}
}
This is my code above and error shown blow I am fresher in CodeIgniter I need help
This is an error
Upvotes: 0
Views: 66
Reputation: 342
public function _construct()
{
parent::_construct();
$this->load->model('employee_model');
$this->load->helper(array('form','url'));
private $employee_model = 'employee_model';
}
First set it in construct and then, call it like this
$this->{employee_model}->saveemployee($save);
Upvotes: 0
Reputation: 65
Alway model name is start from capital letter. First fixd that. Then chek database setting
Upvotes: 1
Reputation: 21
You have to load the db library first. In
autoload.php :
$autoload[‘libraries’] = array(‘database’);
Upvotes: 0