Ошибка при пагинации. ругается на переменную count в movies.php. в чем может быть ошибка?
Томиленко Варвара2 ответов
public function type($slug=NULL)
{
$this->load->library('pagination');
$this->data['movie_data'] = NULL;
$offset = (int)$this->uri->segment(4);
$row_count = 2;
$count = 0;
if ($slug == 'films') {
$count = count($this->films_model->getFilms(0, 1)); //Ругается на эту строку: count(): Argument #1 ($var) must be of type Countable|array, null given
$p_config['base_url'] = 'movies/type/films/';
$this->data['title'] = 'Фильмы';
$this->data['movie_data'] = $this->films_model->getMoviesOnPage($row_count, $offset, 1);
}
if ($slug == 'serials') {
$count = count($this->films_model->getFilms(0, 2));
$p_config['base_url'] = 'movies/type/serials/';
$this->data['title'] = 'Сериалы';
$this->data['movie_data'] = $this->films_model->getMoviesOnPage($row_count, $offset, 2);
}
if ($this->data['movie_data'] == NULL) {
show_404();
}
//Pagination code
$p_config['base_rows'] = $count;
$p_config['per_page'] = $row_count;
//Init pagination
$this->pagination->initialize($p_config);
$this->data['pagination'] = $this->pagination->create_links();
$this->load->view('templates/header', $this->data);
$this->load->view('movies/type', $this->data);
$this->load->view('templates/footer');
}