| 제목 | p.94 쪽 데이터베이스 에러 관련 질문입니다(ㅠ.ㅠ) | ||
|---|---|---|---|
| 글쓴이 | 오리엔탈바가지 | 작성시각 | 2015/08/03 20:08:42 |
|
|
|||
|
안녕하세요? 정말 생 기초적인 지식만을 가지고 코딩 하다가 코드이그니터를 알게 되서 관심을 가지고 책을 사서 열심히 저한테 맞게 따라만들고 있는 사람입니다. 다름이 아니라, 페이지 네이션 할 때 에러가 떠서요 ㅠ.ㅠ 해당 구문은 A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'count,' at line 1 SELECT * FROM board_free order by b_no desc LIMIT count, Filename: C:/APM_Setup/htdocs/application/models/test_model.php Line Number: 18 요렇게 뜨네요. 해당 18번째 줄에 있는건 제목 : test_model
08 function get_list($type='', $offset='', $limit='')
09 {
10 $limit_query = '';
11
12 if( $limit != '' OR $offset != ''){
13 //페이징이 있을 경우의 처리
14 $limit_query = ' LIMIT '.$offset.','.$limit;
15 }
16
17 $sql = 'SELECT * FROM board_free order by b_no desc'.$limit_query;
18 $query = $this->db->query($sql);
19 if ( $type == 'count' )
20 {
21 $result = $query->num_rows();
22 //$this->db->count_all($table);
23 }
24 else
25 {
26 $result = $query->result();
27 }
28 return $result;
(걍 참고 사항으로 책과 거의 같긴 한데 컨트롤러도 올리겠습니다..) |
|||
| 다음글 | Runtime Notice 에러를 못잡겠습니다. . (2) | ||
| 이전글 | session로드하는 부분 막혀서 질문드립니다. (4) | ||
|
변종원(웅파)
/
2015/08/03 21:03:41 /
추천
0
|
$config['total_rows'] = $this->test_model->get_list($this->uri->segment(3), 'count'); <-- 이 부분이 문제네요.
두번째 세그먼트로 count를 넘겼으니 당연히 $limit_query가 limit count, 가 되어서 에러가 나는겁니다.
get_list 함수에는 파라미터를 꼭 3개 넘겨야 제대로 작동하며 2, 3번째 파라미터는 숫자이어야 합니다.