codeigniter active record get query and query without the LIMIT clause

前端 未结 4 1945
梦谈多话
梦谈多话 2020-12-13 21:41

im using active record, its all working ok but i want to set the $data[\"totalres\"] to the total results, i mean, the same query but without the LI

4条回答
  •  余生分开走
    2020-12-13 21:46

    $this->db
    ->select("SQL_CALC_FOUND_ROWS emp", FALSE)
    ->from('emp')
    ->join('empr', 'empr.b = empr.id', 'left')
    ->like('code', $code)
    ->limit($numrows, $start); $q = $this->db->get();
    
    $query = $this->db->query('SELECT FOUND_ROWS() AS `Count`');
    $data["totalres"] = $this->db->get()->row()->Count;
    

    CodeIgniter 2.1.0 not run, below code will fix it.

    $query = $this->db->query('SELECT FOUND_ROWS() AS `Count`');
    $objCount = $query->result_array();
    $data["totalres"] = $objCount[0]['Count'];
    

提交回复
热议问题