CI 묻고 답하기

제목 초보 질문.. 페이징 관련 하여 GET 처리
글쓴이 DJ구스 작성시각 2011/10/27 14:04:12
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 17336   RSS
백만년 만에 기존 개발 했던 소스 없이 첨부터 만들다 보니 기억이 가물 가물 5년만에 다시 CI를 접하고 나니.. 

기본적인 초보 질문을 해도 될까요? 물론 2일동안 구굴링 부터 질답 검색을 해봤지만 제가 원한는 답을 못찾아서요..


게시물을 검색 할 때 보통 pagination 때문에 GET으로 처리를 하는데.. 
게시물 입력 필드를 form_validation 으로 체크를 하려고 하다보니..
이상하게도 GET으로 넘어 오면 체크를 못하는데 원래 GET방식은 처리를 안하나요?

오로지 POST만 처리했던거 같기도 하고 아니였던거 같기도 하고..
혹시 같은 경험이 있으시면 답변좀..

사실 form_validation 으로 에러 처리 안하고 js해도 되는데 일단 둘다 해놓고 
기억을 더듦고자 되는지 안되는지 기본 이해와 원리를 공부 하려다 보니 질문을 올립니다..^^;

일단 우선 JS로 입력값 체크 후 form_validation 은 제거 하고 처리 해서 paging 구현해야겠습니다.
 function lists($intOffset = 0)
 {
  $this->load->library('pagination');
  $this->load->library('form_validation');
  $this->config->load('pagination');

  $this->form_validation->set_error_delimiters('<div class="dialog-box-error-small-box corners"><p><b>Error!!  ','</b> </p><div class="delx-box"></div></div>');

  /*
   * 0: 탈퇴회원
   * 1: 준회원
   * 2: 정회원
   * 3. 우수회원
   */

  $arrUserCount = array(
   'count_ban_user' => $this->mod_user->get_user_count_all('0'),
   'count_un_user'  => $this->mod_user->get_user_count_all('1'),
   'count_user'  => $this->mod_user->get_user_count_all('2'),
   'count_vip_user' => $this->mod_user->get_user_count_all('3'),
   'count_all_user' => $this->mod_user->get_user_count_all()
  );

  $arrWhere = array();
  // 키워드 검색
  if ( FALSE !== $this->input->get('s_id_type') )
  {
   // 검색어 검색
   $this->form_validation->set_rules('s_keyword', ' 검색어', 'trim|required|xss_clean|min_length[4]|max_length[20]');
   // validation ok
   if ( TRUE === $this->form_validation->run() )
   {
    alert($this->input->get('s_id_type'));

    switch ( $this->input->get('s_id_type') )
    {
     case 'id'   : $arrWhere = array('user_id' => $this->input->get('s_keyword')); break;
     case 'xx_id' : $arrWhere = array('xx_id'  => $this->input->get('s_keyword')); break;
     case 'nick_name': $arrWhere = array('nick_name' => $this->input->get('s_keyword')); break;
    }
   }
  }
  else if ( FALSE !== $this->input->get('s_user_type') )
  {
   $arrWhere = array('user_type' => $this->input->get('s_user_type') );
  }
  else if ( FALSE !== $this->input->get('s_date') )
  {
   $arrWhere = "last_login > DATE_ADD( NOW(), INTERVAL -{$this->input->get('s_date')} MONTH)";
  }
  
  // pagination setting
  $config['base_url'] = '/bo/user/lists/';
  // URL 자리수
  $config['uri_segment'] = 4;
  // 페이지당 보여줄 게시물 수
  $config['per_page'] = 10;
  // 게시물 가지고 오기
  $arrResult = $this->mod_user->get_user_info_lists($arrWhere, $config['per_page'], $intOffset );
  // 페이징 생성
  $config['total_rows'] = $arrResult['total_rows'];
  $this->pagination->initialize($config);

  $this->template->assign(array(
          'admin_info' => $this->session,
          'user_list' => $arrResult['query']->result_array(),
          'user_count' => $arrUserCount,
          'pagination' => $this->pagination->create_links()
        ));


  $this->template->define('user', 'bo/user.tpl');
  $this->template->print_('user');
 }

 다음글 index.php 없애는 방법 문의 드립니다. (5)
 이전글 문의드립니다.. (3)

댓글

변종원(웅파) / 2011/10/27 14:25:12 / 추천 0
코어 소스를 봐야 정확하겠지만 form_validation에 값 넘길때 form에서 method를 post로 하죠.
그걸 get으로 바꾸고 테스트해보면 답이 나올거 같네요.

get도 될지, form_validation이 post만 될지. ^^
한대승(불의회상) / 2011/10/27 14:31:07 / 추천 0
from_validation 은 POST에 대해서만 동작 되도록 되어 있네요 ^^


한대승(불의회상) / 2011/10/27 14:46:52 / 추천 0
꼼수를 쓰자면...

요렇게 함 해보세요 ^^

$_POST['s_keyword'] = $this->input->get('s_keyword');

// 검색어 검색
$this->form_validation->set_rules('s_keyword', ' 검색어', 'trim|required|xss_clean|min_length[4]|max_length[20]');
// validation ok
if ( TRUE === $this->form_validation->run() )