gpt4 book ai didi

php - 无法在 Codeigniter 中定位指定类 : Session. php

转载 作者:可可西里 更新时间:2023-11-01 13:02:52 26 4
gpt4 key购买 nike

浏览器:

无法定位指定类:Session.php

这是我的 Controller :

<?php

class Chat extends CI_Controller {

public function __construct() {

parent::__construct();
$this->load->model('Chat_model');
}

public function index() {

$this->view_data['chat_id'] = 1;
$this->view_data['student_id'] = $this->session->userdata('student_id');
$this->view_data['page_content'] = 'chat';
$this->load->view('chat');
}

public function ajax_addChatMessage() {

$chat_id = $this->input->post('chat_id');
$student_id = $this->input->post('student_id');
$bericht = $this->input->post('chat_id', TRUE);

$this->Chat_model->addChatMessage($chat_id, $student_id, $bericht);
}
}

当我将我的模型放在 parent::__construct(); 的注释中时;//$this->load->model('Chat_model'); 错误消失了。

这是我的聊天模型:

<?php

class Chat_model extends CI_Controller {

public function Chat_model() {
parent::__construct();
}

public function addChatMessage($chat_id, $student_id, $bericht) {

$query = "INSERT INTO tbl_chatberichten (chat_id, student_id, bericht) VALUES (?,?,?)";
$this->db->query($query, array($chat_id, $student_id, $bericht));

}

}

最佳答案

class Chat_model extends CI_Controller

应该是

class Chat_model extends CI_Model

关于php - 无法在 Codeigniter 中定位指定类 : Session. php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29841942/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com