Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Kueri catatan aktif Codeigniter membutuhkan terlalu banyak waktu untuk memuat data dari database

Gunakan pagination ini adalah cara terbaik untuk menggunakannya

buat ini agar berfungsi dalam model

Model

public function get_count($table){
        return $this->db->count_all_results($table);
    }

    public function get_all_userdata($table, $where, $limit, $start){
        $query = $this->db->get_where($table, $where, $limit, $start);
        $data = $query->result_array();
        return $data;
    }

Pengontrol

$where = array('status' => 0);
         //pagination
        $config['base_url'] = base_url('nonactiveusers');
        $config['total_rows'] =  $this->User_model->get_count();
        $config['per_page'] = 5;
        $config["num_links"] = 3;
        $config['uri_segment'] = 2;

        $config['full_tag_open'] = "<ul class='pagination'>";
        $config['full_tag_close'] ="</ul>";
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
        $config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
        $config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
        $config['next_tag_open'] = "<li>";
        $config['next_tag_close'] = "</li>";
        $config['prev_tag_open'] = "<li>";
        $config['prev_tag_close'] = "</li>";
        $config['first_tag_open'] = "<li>";
        $config['first_tag_close'] = "</li>";
        $config['last_tag_open'] = "<li>";
        $config['last_tag_close'] = "</li>";

        $config['first_link'] = "<<";
        $config['last_link'] = ">>";


        $this->pagination->initialize($config);
        $page = $this->uri->segment(3); // your uri segment here
        $data['links'] = $this->pagination->create_links();
        $result = $this->User_model->get_all_userdata("users", $where, $config['per_page'], $page);

        $data['users'] = $result;
        $this->load->view('view', $data);


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Cara Menginstal MySQL Di Ubuntu

  2. Pemodelan Varian Produk

  3. Bisakah saya menggunakan kembali bidang terhitung dalam kueri SELECT?

  4. Tentukan file konfigurasi MySQL mana yang digunakan

  5. Permintaan MySQL untuk menggabungkan dan mencari dalam 2 tabel