Помогите разобраться ошибкой в undefined property в codeigniter?
уже 3 день застрял на уроке кодегнитер
никак не могу понять сам и на форумах не нашел ответ
если тут есть ктото кто овладел достаточным знанием php codeigniter прошу помогите
уже 3 пост пишу.....
дело в том что у меня таблица фильмов и сериалов по одтельности и называються movie,serial так вот на главной странице виводит информаци из movie и serial тоесть показывает по 8 фильмов и сериалов но вот когда создал страницу просмотра фильмов фильмы открываються но сериалы нет и также станица со списком фильмов создается где вывожу список 15 фильмов а страница с сериалами не работает при просмотре сериала и и при виводе страницы сериалов ошибка.ниже вставлю код и еще раз прошу помогите
Models:
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();
}
}
controllers:
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');
}
}
main:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Main extends MY_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$this->data['title'] = "Main Page";
$this->load->model('films_model');
$this->data['movie'] = $this->films_model->getFilms(false, 8, 1);
$this->load->model('serials_model');
$this->data['serial'] = $this->serials_model->getSerials(false, 8, 2);
$this->load->view('templates/header', $this->data);
$this->load->view('main/index', $this->data);
$this->load->view('templates/footer');
}
}
my_controller:
<?php
class MY_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
$this->data['title'] = "Movie World - All Best in One Place";
$this->load->model('news_model');
$this->data['news'] = $this->news_model->getNews();
$this->load->model('films_model');
$this->data['films'] = $this->films_model->getFilmsByRating(10);
}
}
route:
$route['default_controller'] = 'main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['movies/(:any)'] = 'movies/view/$1';
$route['serials/(:any)'] = 'serials/view/$1';
$route['news'] = 'news';
$route['news/create'] = 'news/create';
$route['news/edit'] = 'news/edit';
$route['news/delete'] = 'news/delete';
$route['news/(:any)'] = 'news/view/$1';
Ошибка которую выдает при просмотре сериалов
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