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); 처럼 숫자로 바꾸어봐도 안됩니다.)
이럴경우 쿼리를 원문으로 만든다음에
쿼리 원문확인하고 직접 디비에 날려보면 좀더 쉽게 접근할 수 있을겁니다.