这是我的型号:
class Medecin_model extends CI_Model
{
public $fillable = array('nom','prenom','genre','adresse','date_naissance','specialiter','servise','grade','etablissement','type_personne');
public $id_medecin;
public $nom;
public $prenom;
public $genre;
public $adresse;
public $date_naissance;
public $specialiter;
public $service;
public $grade;
public $etablissement;
public $type_personne = Medecin;
public function insert($nom, $prenom, $genre, $adresse, $date_naissance, $specialiter, $service, $grade, $etablissement)
{
$this->nom=$nom;
$this->prenom=$prenom;
$this->genre=$genre;
$this->adresse=$adresse;
$this->date_naissance=$date_naissance;
$this->specialiter=$specialiter;
$this->service=$service;
$this->grade=$grade;
$this->etablissement=$etablissement;
// $this->db->insert('personne', $this);
}
这是我的控制器:
defined('BASEPATH') OR exit('No direct script access allowed');
class Medecin extends CI_Controller
{
public function index()
{
$this->load->view('header');
$this->load->view('ajout_medecin');
$this->load->view('footer');
}
public function ajout()
{
$this->load->model("Medecin_model");
$nom=$this->input->post('first-name');
$prenom=$this->input->post('last-name');
$genre=$this->input->post('genre');
$adresse=$this->input->post('adress');
$date_naissance=$this->input->post('birthday');
$specialiter=$this->input->post('speciality');
$service=$this->input->post('service');
$grade=$this->input->post('grade');
$etablissement=$this->input->post('establishment');
$doctor = new Medecin_model();
$doctor->insert($nom, $prenom, $genre, $adresse, $date_naissance, $specialiter, $service, $grade, $etablissement);
}
我收到一条错误消息:
遇到PHP错误严重性:注意消息:使用未定义的常量Medecin-假定为"Medecin"文件名:core/Loader.php行号:357回溯:文件:C: \wamp64\www\CodeIgniter\application\controlles\Medecin.php行:23函数:model文件:C:\wamp64\www\CodeIgniter\index.php行:315功能:需要一次
Medecin
周围缺少''
更换
public $type_personne = Medecin;
使用此
public $type_personne = 'Medecin';