당신은 카운트를 얻기 위해 두 개의 쿼리 하나를 사용할 수 있습니다 다른 하나는 제한된 결과를 반환합니다. 모델 만
변수 수를 반환하는 함수를 작성하고 페이지가 매겨진 결과를 생성하는 두 번째 함수를 작성처럼
.
예 ..
public function count($where){
$query = $this->db->query("select count(id) as count from clients $where");
return $query->row('count');
}
}
public function limit($sidx,$sord,$start,$limit,$where){
$query = $this->db->query("select * from clients $where ORDER BY $sidx $sord LIMIT $start , $limit");
if ($query->num_rows() > 0){
return $query->result_array();
}
}
그리고 여기 컨트롤러 코드를
$를 어디로 = //
$count = count($this->model->count($where));
if($count > 0) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; }
if ($page > $total_pages) $page = $total_pages;
$start = $limit * $page - $limit;
$users = $this->model->limit($sidx,$sord,$start,$limit,$where);
계산 ............. ....
완벽하게 작동했습니다. 고마워요 :) –