0
특정 검색을 위해 반환 된 데이터 행을 관리했지만 발견 된 행 수를 얻을 수 없습니다. 여기에 내 코드Codeigniter에서 db 쿼리 후 행 수를 얻으려면 어떻게해야합니까?
내 컨트롤러 도움이된다면
function get_search($keyword)
{
$q = $this-> db-> select('*')-> from ('blog');
$q= $this->db->like('title',$keyword);
$q= $this->db->or_like('description',$keyword);
$results['rows']= $q-> get()-> result();
//$results['num_rows']= $q-> num_rows(); <--- this doesn't work, invalid method, commented out
return $results;
}
는,이 http://ellislab.com/codeigniter/user-guide/database/results.html 당신을 도울 수있을
function searchdata(){
$result = $this->posts->search($_POST['searchterm']);
$data['posts']= $result['rows'];
$data['num_results']= $result['num_rows']; // num_rows is the number of rows returned from a search
$this-> load-> view('results_index',$data);
}
내 모델입니다. 나는 그것이라고 생각했다
고마워.
완벽하게 작동합니다. 이 오류가 다시 발생할 때 나는이 것들에 대해 더 많은주의를 기울일 것입니다. 감사! – Matt