CI 묻고 답하기

제목 Unknown column 'b_no' in 'where clause' 에러.
글쓴이 수야디벨 작성시각 2012/12/20 15:11:05
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 22359   RSS


Unknown column 'b_no' in 'where clause' 에러가 나는데 왜 나는건지 모르겠습니다.

DB에 저장되어 있는 글을 업데이트 하기 위해서 UPDATE문을 사용하는 도중에 난 에러인데요.

controller에서 ..

$index= $this->uri->segment(4);
$b_no = $this->uri->segment(5);
   
$data = array(
    'b_no' => $b_no,
    index'=>$station_index,
    'categoryNo' => $this->input->post('categoryNo'),
    'b_type' => $this->input->post('b_type'),
    's_no' => $this->input->post('s_no'),
    'title' => $this->input->post('title'),
    'spot' => $this->input->post('spot'),
    'contents' => $this->input->post('contents')
);
   
$this->load->model('werail/board/board_model');
$last = $this->board_model->alert($data);


이렇게 모델에 던집니다. 단 , 'b_no' 와 'index'는 업데이트 문을 할 때 쓰지 않을 거라서,
모델에선 또 이렇게 잡아주었습니다.

$b_no = $data['b_no'];
$index = $data[index'];

$query = array(
   'categoryNo' => $data['categoryNo'],
   'b_type' => $data['b_type'],
   's_no' => $data['s_no'],
   'title' => $data['title'],
   'spot' => $data['spot'],
   'contents' => $data['contents']
);
  
$this->db->where('b_no',$b_no);
$this->db->where('index',$index);
$this->db->update('memberInfo',$query);

'b_no' 와 'index'를 따로 변수로 빼고 하나의 query라는 변수로, 업데이트에 필요한 값만 배열을 만들어버린거지요.

그래서 'b_no'와 'index'는 where절로 사용하려고 위 처럼 하니까

Unknown column 'b_no' in 'where clause'  에러가 나네요 ..

왜 그런걸까요?

(ps. $this->db->where('b_no',$b_no); 을 $this->db->where('b_no',140); 처럼 숫자로 바꾸어봐도 안됩니다.)
 

 다음글 CI 폴더 변경시 질문드립니다. (4)
 이전글 글로벌 변수로 해야할지, 다른 방법이 있을지. (3)

댓글

니삼 / 2012/12/20 15:14:45 / 추천 0
오류는 b_no컬럼이 없다다고 하는대..음
이럴경우 쿼리를 원문으로 만든다음에
쿼리 원문확인하고 직접 디비에 날려보면 좀더 쉽게 접근할 수 있을겁니다.
수야디벨 / 2012/12/20 15:23:40 / 추천 0
니삼//

감사합니다 :)

원문으로 접근해서 해결했습니다.

정말로 컬럼이 없던거군요 ㅠ 제가 착각을 했었습니다