Ошибка undefined property в функции edit и delete?

0

Помогите пожалуйста! не могу понять в чем дело. Ошибка

A PHP Error was encountered
Severity: Notice

Message: Undefined property: Comments::$Сomments_model

Filename: controllers/Comments.php

Line Number: 78

Backtrace:

File: C:\xampp\htdocs\Khvoya\application\controllers\Comments.php
Line: 78
Function: _error_handler

File: C:\xampp\htdocs\Khvoya\index.php
Line: 315
Function: require_once

Код контроллера Comments.php

<?php

defined('BASEPATH') OR exit ('No direc script access allowed');

class Comments extends MY_Controller {

	public function __construct () {
		parent::__construct();
		$this->load->model('Comments_model');
	}
        public function edit($slug = NULL) {

		if(!$this->dx_auth->is_admin()) {
			$this->load->view('news/netdostupa', $this->data);
		}

		$this->data['title'] = "Редактировать отзыв";
		$this->data['comments_item'] = $this->Сomments_model->getСomments($slug);

			$this->data['slug_comments'] = $this->data['comments_item']['slug'];
			$this->data['title_comments'] = $this->data['comments_item']['title'];
			$this->data['image_comments'] = $this->data['comments_item']['image'];
			$this->data['content_comments'] = $this->data['comments_item']['text'];
			$this->data['data_comments'] = $this->data['comments_item']['data'];
			
			
			if($this->input->post('slug') && $this->input->post('title') && $this->input->post('image')&& $this->input->post('text') && $this->input->post('data')) {
				$slug = $this->input->post('slug');
				$title = $this->input->post('title');
				$image = $this->input->post('image');
				$text = $this->input->post('text');
				$data = $this->input->post('data');

				if($this->Сomments_model->updateСomments($slug,$title,$image,$text,$data)) {
					$this->load->view('templates/header', $this->data);
					$this->load->view('news/success', $this->data);
					$this->load->view('templates/footer');
				}

			} else {

				$this->load->view('templates/header', $this->data);
				$this->load->view('сomments/edit', $this->data);
				$this->load->view('templates/footer');
				}
		
	}

Код модели Comments_model

<?php

class Comments_model extends CI_Model {

	public function __construct() {
		$this->load->database();
	}

	public function getComments($slug = FALSE) {
		if($slug === FALSE) {
			$query = $this->db->get('comments');
			return $query->result_array();
		}

		$query = $this->db->get_where('comments', array('slug' => $slug));
		return $query->row_array();
	}

	public function setComments($slug, $title, $image, $text, $data) {

		$data = array(
			'slug' => $slug,
			'title' => $title,
			'image' => $image,
			'text' => $text,
			'data' => $data
			
		);

		return $this->db->insert('comments',$data);
	}

	public function updateComments($slug, $title, $image, $text, $data) {

		$data = array(
			'slug' => $slug,
			'title' => $title,
			'image' => $image,
			'text' => $text,
			'data' => $data
		);

		return $this->db->update('comments',$data, array('slug' => $slug));
	}

	public function deleteComments($slug) {
		return $this->db->delete('comments', array('slug' => $slug));
	}
}

codeigniter

2 ответов

1

В этом коде что-то не так с названием. Я думаю, что где-то здесь из русской раскладки клавиатуры буквы добавились в название:

$this->Сomments_model->updateСomments

Попробуйте удалить эту строчку и еще раз написать в английской раскладке клавиатуры.

1

student_Y7yoWdC7 сердечно вас благодарю! Вы Бог! Мой куриный мозг до этого не додумался.

Sign up or Log in to write an answer