使用未定义的常量Medecin-在Codeigniter中假定为“ Medecin”

时间:2018-07-20 13:56:24

标签: php codeigniter codeigniter-3 codeigniter-query-builder

这是我的模特:

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 \ controllers \ Medecin.php行:23   函数:模型文件:C:\ wamp64 \ www \ CodeIgniter \ index.php行:315   功能:require_once

1 个答案:

答案 0 :(得分:1)

''周围缺少Medecin

替换

public $type_personne = Medecin; 

使用此

public $type_personne = 'Medecin';