У меня сайт для просмотра фильмов онлайн. Так вот у меня в базе данных 52 фильмов, а на странице выводит только 20 при пагинации по 10 на страницу. Не могу понять почему. Может кто подскажет что я неправильно делаю?
Ниже вставлю коды:
это модель 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('year', 'desc')
->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();
}
public function getMoviesOnPage($row_count, $offset, $type = 1) {
$query = $this->db
->where('category_id', $type)
->order_by('year', 'desc')
->get('movie', $row_count, $offset);
return $query->result_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->load->library('pagination');
$this->data['movie_data'] = NULL;
$offset = (int) $this->uri->segment(4);
$row_count = 10;
$count = 0;
if($slug == "films") {
$count = count($this->films_model->getFilms(0, 1));
$p_config['base_url'] = '/movies/type/films/';
$this->data['title'] = "Movies";
$this->data['movie_data'] = $this->films_model->getMoviesOnPage($row_count, $offset, 1);
}
if($this->data['movie_data'] == null) {
show_404();
}
$p_config['total_rows'] = $count;
$p_config['per_page'] = $row_count;
$p_config['full_tag_open'] = "<ul class='pagination'>";
$p_config['full_tag_close'] ="</ul>";
$p_config['num_tag_open'] = '<li>';
$p_config['num_tag_close'] = '</li>';
$p_config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$p_config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$p_config['next_tag_open'] = "<li>";
$p_config['next_tagl_close'] = "</li>";
$p_config['prev_tag_open'] = "<li>";
$p_config['prev_tagl_close'] = "</li>";
$p_config['first_tag_open'] = "<li>";
$p_config['first_tagl_close'] = "</li>";
$p_config['last_tag_open'] = "<li>";
$p_config['last_tagl_close'] = "</li>";
$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');
}
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');
}
}