codeigniter count_all_results

后端 未结 7 1781
眼角桃花
眼角桃花 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 03:59

    The

    $this->db->count_all_results();
    

    actually replaces the:

    $this->db->get();
    

    So you can't actually have both.

    If you want to do have both get and to calculate the num rows at the same query you can easily do this:

    $this->db->from(....);
    $this->db->where(....);
    $db_results = $this->get();
    
    $results = $db_results->result();
    $num_rows = $db_results->num_rows();
    

提交回复
热议问题