sql >> Database >  >> RDS >> Mysql

Codeigniter active records query kost te veel tijd om gegevens uit de database te laden

Gebruik paginering dit is de beste manier om het te gebruiken

maak deze om in het model te functioneren

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;
    }

Controller

$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. SQLite - Zet een database neer

  2. kopieer databasestructuur zonder gegevens in mysql (met lege tabellen)

  3. Hoe vraag ik tussen twee datums met MySQL?

  4. Twee SQL-query's uitvoeren op één php-pagina (SET + SELECT)