CI 묻고 답하기

제목 Update문이 실행이 되질 않아요...
글쓴이 기린이 작성시각 2014/11/03 18:53:32
댓글 : 11 추천 : 0 스크랩 : 0 조회수 : 12270   RSS
컨트롤러에서 이렇게 구현하였구요

//선택한 년도
        $select_year = $this->input->post('select_year');        
        if(empty($select_year)) { $select_year=date('Y'); }
        $this->set('selectYear',$select_year);

        //수정
        if($this->form_validation->run() != FALSE){
            //$year = $this->input->post('year');
            $month = $this->input->post('month');
            $in_redist = $this->input->post('in_redist');
            $out_redist = $this->input->post('out_redist');
            $in_export_j = $this->input->post('in_export_j');
            $in_export_g = $this->input->post('in_export_g');
            $in_import_j = $this->input->post('in_import_j');
            $in_import_g = $this->input->post('in_import_g');
            $out_export_j = $this->input->post('out_export_j');
            $out_export_g = $this->input->post('out_export_g');
            $out_import_j = $this->input->post('out_import_j');
            $out_import_g = $this->input->post('out_import_g');
            $amount = $this->input->post('amount');
        
            if(!empty($month)){
                for($i=0, $e=count($month); $i<$e; $i++) {
                $data = array(
                    'in_redist' => $in_redist[$i],
                    'out_redist' => $out_redist[$i],
                    'in_export_j' => $in_export_j[$i],
                    'in_export_g' => $in_export_g[$i],
                    'in_import_j' => $in_import_j[$i],
                    'in_import_g' => $in_import_g[$i],
                    'out_export_j' => $out_export_j[$i],
                    'out_export_g' => $out_export_g[$i],
                    'out_import_j' => $out_import_j[$i],
                    'out_import_g' => $out_import_g[$i],
                    'amount' => $amount[$i]
                );
                $this->db->where('year', $select_year);
                $this->db->update('테이블명', $data);
                }
            }
            
            go_url('url', 'top');
        }

view파일에서는
제이쿼리이용하여

$("a.save").click(function(){
        $(this).closest("form").submit();
    });

<a href="#" class="btn01 save" id="btn_save"><span>저장</span></a>

이렇게 실행이 되는데요....

그럼 저장버튼을 누르면
컨트롤러 코드에 밑줄 그어진 부분쪽으로 진입하여 update되어야 하는거 아닌가요 ㅜㅜ?
자꾸 업데이트가 안되네요....ㄷㄷ;;


어디가문제일까요
 다음글 codeigniter와 이클립스나 젠드스튜디오 사용시 ... (6)
 이전글 CI와 wordpress 연동하였습니다. (3)

댓글

한대승(불의회상) / 2014/11/04 07:14:41 / 추천 0
$month 가 empty 인가 보네요.
들국화 / 2014/11/04 09:25:24 / 추천 0
쿼리문을 찍어보세요.
기린이 / 2014/11/04 10:37:10 / 추천 0
한대승/ $month 가 안들어가는거더라구요... 그래서 빼보기도했는데 안되네요 ㅜㅜ
들국화/ 쿼리문 어떻게 찍죠!? echo문쓰면 에러뜨는데 자꾸....ㄷㄷ;; 잘모르겠어요 ㅜㅜ(페이지를 표시할수 없습니다)
들국화 / 2014/11/04 10:59:13 / 추천 0
쿼리문 끝에 echo $this->db->last_query();die(); 넣어서 찍어 보세요.
기린이 / 2014/11/04 14:31:29 / 추천 0
들국화 / 아무런 반응이 없는걸보니.... 여기로 진입을 안했나보네요 ㅜㅜ 다른곳에서 문제일까요
들국화 / 2014/11/04 14:33:24 / 추천 0
에러로그를 보거나 중간중간 브레이크를 걸어서 디버깅 해보세요.
한대승(불의회상) / 2014/11/04 14:49:05 / 추천 0
last_query 결과 값이 없다는건 DB에 쿼리를 날리지 않았다는거죠.
kaido / 2014/11/04 15:02:17 / 추천 0
이런 문제일 수록 작은 실수 일 가능성이 높습니다.

뷰에서 <form>  안넣으신것 아닌가요?
기린이 / 2014/11/04 15:22:04 / 추천 0
다들 감사드립니다 ㅜㅜ 다시 다 확인 해봐야겠네요!
kaido/ form이런건 다들어와있어요.... 예전에 update문은 되던거라.... 어딘가 수정하면서 안되나 확인해봐야 할꺼 같습니다~
들국화/ 감사합니다! 천천히 다시 알아봐야겠네요....
한대승/ 그런거 같네요.... ㅜㅜ 코드이그나이터를 이제막공부하다보니 햇깔리네요...ㅋㅋ 
한대승(불의회상) / 2014/11/04 15:30:35 / 추천 0
기린이// $this->output->enable_profiler() 를 사용해 보세요.
분명 도움이 되실겁니다. ^^

 
기린이 / 2014/11/04 15:49:30 / 추천 0
한대승/ 감사합니다!^^