codeigniter count_all_results

后端 未结 7 1762
眼角桃花
眼角桃花 2021-02-14 03:37

I\'m working with the latest codeIgniter released, and i\'m also working with jquery datatables from datatables.net

I

7条回答
  •  广开言路
    2021-02-14 04:01

    $this->db->count_all_results() replaces $this->db->get() in a database call.

    I.E. you can call either count_all_results() or get(), but not both.

    You need to do two seperate active record calls. One to assign the results #, and one to get the actual results.

    Something like this for the count:

    $this->db->select('id');
    $this->db->from('table');
    $this->db->where($your_conditions);
    $num_results = $this->db->count_all_results();
    

    And for the actual query (which you should already have):

    $this->db->select($your_columns);
    $this->db->from('table');
    $this->db->where($your_conditions);
    $this->db->limit($limit);
    $query = $this->db->get();
    

提交回复
热议问题