Browser:
Unable to find the specified class: Session.php
This is my 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); } }
When I put my model in a comment in parent::__construct(); // $this->load->model('Chat_model'); parent::__construct(); // $this->load->model('Chat_model'); , the error has disappeared.
This is my 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)); } }
source share