對於某個表的不帶條件的count,能夠簡單的用html
$total = $this->db->count_all($table_name)ide
來獲取,可是若是有條件,則要用count_all_resultspost
$this->db->where('sex', 'M');ui
$this->db->from('user');this
$total = $this->db->count_all_results();url
CI的pagination庫能夠幫助添加分頁連接,用法能夠看user_guide/libraries/pagination.htmlspa
有幾點須要說明。.net
base_url裏邊若是有超過2個uri_segments,則須要設置$config['uri_segment'] = base_url_segments + 1htm
也就是uri_segment默認是3。若是不設置的話,第一頁和前一頁,後一頁的連接都不正確。blog