jumberi
@jumberi

Что не так с кодом в Codeigniter?

может кто поможе что не так с моим кодом?у меня саайт онлайн фильмов
база данных с тремя отдельними таблицами-фильмы,сериалы,анимация
так во на главной страице портала виводит инфо из базы даных,отображаються и фильмы и сериалы но кода делаю страницу просмотра там уже с сериалами ошибка
вот коды страниц:
код модели Films_model
<?php
class Films_model extends CI_Model {

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

    public function getFilms($slug = FALSE, $limit, $type = 1) {
        if($slug === FALSE) {
            $query = $this->db
                ->where('category_id', $type)
                ->order_by('add_date')
                ->limit($limit)
                ->get('movie');

            return $query->result_array();    
        }

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

    public function getFilmsByRating($limit) {
        $query = $this->db
            ->order_by('rating', 'desc')
            ->where('category_id', 1)
            ->where('rating>', 0)
            ->limit($limit)
            ->get('movie');

        return $query->result_array();    
    }
}

а это код модели Serials_model
<?php

class Serials_model extends CI_Model {

    public function __construct() {
        $this->load->database();
    }
    
    public function getSerials($slug = FALSE, $limit, $type = 2) {
        if($slug === FALSE) {
            $query = $this->db
                ->where('category_id', $type)
                ->order_by('add_date', 'desc')
                ->limit($limit)
                ->get('serial');

            return $query->result_array();
        }

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

}


это код контролера Movies
<?php

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

class Movies extends MY_Controller {

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

    public function type($slug = NULL) {
        $this->data['movie_data'] = NULL;

        if($slug == "films") {
            $this->data['title'] = "Movies";
            $this->data['movie_data'] = $this->films_model->getFilms(false, 10, 1);
        }

        $this->load->view('templates/header', $this->data);
        $this->load->view('movies/type', $this->data);
        $this->load->view('templates/footer');
    }

    public function view($slug = NULL) {

        $movie_slug = $this->films_model->getFilms($slug, false, false);

        if(empty($movie_slug)) {
            show_404();
        }

        $this->data['title'] = $movie_slug['name'];
        $this->data['year'] = $movie_slug['year'];
        $this->data['rating'] = $movie_slug['rating'];
        $this->data['descriptions_movie'] = $movie_slug['descriptions'];
        $this->data['player_code'] = $movie_slug['player_code'];
        $this->data['director'] = $movie_slug['director'];

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


}


а это код контролера Serials
<?php

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

class Serials extends MY_Controller {

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


    public function view($slug = NULL) {

        $serial_slug = $this->serials_model->getSerials($slug, false, false);

        if(empty($serial_slug)) {
            show_404();
        }

        $this->data['title'] = $serial_slug['name'];
        $this->data['year'] = $serial_slug['year'];
        $this->data['rating'] = $serial_slug['rating'];
        $this->data['descriptions_movie'] = $serial_slug['descriptions'];
        $this->data['player_code'] = $serial_slug['player_code'];
        $this->data['director'] = $serial_slug['director'];

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


}


а вот ошибка которая всплывает
A PHP Error was encountered
Severity: Notice

Message: Undefined property: Serials::$serials_model

Filename: controllers/Serials.php

Line Number: 14

Backtrace:

File: C:\xampp\htdocs\movieworld\application\controllers\Serials.php
Line: 14
Function: _error_handler

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

An uncaught Exception was encountered
Type: Error

Message: Call to a member function getSerials() on null

Filename: C:\xampp\htdocs\movieworld\application\controllers\Serials.php

Line Number: 14

Backtrace:

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


?>
  • Вопрос задан
  • 86 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы