difference between $query>num_rows() and $this->db->count_all_results() in CodeIgniter & which one is recommended

后端 未结 8 1669
南方客
南方客 2020-12-13 17:50

In a scenario I need to know the count of recordset a query will return, which in codeigniter can be done by $query->num_rows() or $this->db->cou

8条回答
  •  -上瘾入骨i
    2020-12-13 18:32

    Which one is better and what is the difference between these two Its almost imposibble to me, someone just want to get the number of records without re-touching or perform another query which involved same resource. Furthermore, the memory used by these two function is in same way after all, since with count_all_result you still performing get (in CI AR terms), so i recomend you using the other one (or use count() instead) which gave you reusability benefits.

提交回复
热议问题