sql >> Database teknologi >  >> RDS >> Mysql

Codeigniter aktive poster forespørgsel, der tager for lang tid at indlæse data fra databasen

Brug paginering dette er den bedste måde at bruge det på

oprette disse til at fungere i 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;
    }

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. Oprettelse af timer i Oracle Forms / Forms 6i og visning af et ur

  2. opsætning af en venneliste i mysql

  3. 900 byte indeksstørrelsesgrænse i tegnlængde

  4. Jeg får dobbelte resultater fra mysql-forespørgsel, når jeg bruger internationale tegn, dvs. Å/Ä=A &Ö=O,