CI 묻고 답하기

제목 포럼 소스 검색 model 구현에 대한 질문
글쓴이 모숭이 작성시각 2015/08/30 20:56:12
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 13857   RSS
 //통합검색 기능추가 by emc (2009/08/19)
 function search_total($post)
 {

  //print_r($post);
  /*
  if ($post) {
   $this->db->like($post["method"], $post["s_word"]);
    }
    $this->db->where(array('is_delete'=>'N', 'original_no'=>'0'));

  $query = $this->db->get($this->table);
  */

  $field = " no, contents, subject, user_name, user_id, hit, voted_count, reply_count, reg_date ";
        $where = " WHERE (subject like \"%".$post['s_word']."%\" or contents like \"%".$post['s_word']."%\") and is_delete = 'N' and original_no = '0' ";

        $sql = "SELECT b.nickname, a.table, a.tbn, a.no, a.contents, a.subject, a.user_name, a.user_id, a.hit, a.voted_count, a.reply_count, a.reg_date from ( ";
        $sql.= "(SELECT 'CI 묻고 답하기' as 'table', 'qna' as 'tbn', ".$field." FROM board_qna ".$where.") UNION ";
        $sql.= "(SELECT 'TIP게시판'      as 'table', 'tip' as 'tbn', ".$field." FROM board_tip ".$where.") UNION ";
        $sql.= "(SELECT '강좌게시판' as 'table', 'lecture' as 'tbn', ".$field." FROM board_lecture ".$where.") UNION ";
        $sql.= "(SELECT 'CI 코드'     as 'table', 'source' as 'tbn', ".$field." FROM board_source ".$where.") UNION ";
        $sql.= "(SELECT 'CI 뉴스'       as 'table', 'news' as 'tbn', ".$field." FROM board_news ".$where.") UNION ";
        $sql.= "(SELECT '공지사항'    as 'table', 'notice' as 'tbn', ".$field." FROM board_notice ".$where.") UNION ";
        $sql.= "(SELECT '자유게시판'    as 'table', 'free' as 'tbn', ".$field." FROM board_free ".$where.") ";
        if($this->session->userdata('auth_code') >= '7'){
         $sql.= " UNION (SELECT '개발자게시판'    as 'table', 'ci' as 'tbn', ".$field." FROM board_ci ".$where.") ";
     }
        $sql.= " ) as a, users b where a.user_id=b.userid ";
        $sql.= "order by reg_date desc ";

  $rs = $this->db->query($sql);
  //return $rs->result();

        return $rs->num_rows();
 }

///////////////////////////////////////////////////////////질문///////////
1. $where = " WHERE (subject like \"%".$post['s_word']."%\" or contents like \"%".$post['s_word']."%\") and is_delete = 'N' and original_no = '0' ";
와 $sql.= "(SELECT 'CI 묻고 답하기' as 'table', 'qna' as 'tbn', ".$field." FROM board_qna ".$where.") UNION "; 에서 
$where = WHERE(~), $sql .= "(SELECT ~)" 갈호는 왜 씌우는건가요?

2.$sql = "(SELECT 'CI 묻고 답하기' as 'table' ~)로 됬는데 제가 알기로는 
'CI 묻고 답하기'를 table이라는 명칭으로 편리상 둔 것이라고 알고 있는데요...맞는지좀..그리고..
'CI 묻고 답하기'는 어디서 나온건지 설명해주실 수 있을까요????? 


3. $sql = "SELECT b.nickname, a.table, a.tbn, a.no, a.contents, a.subject, a.user_name, a.user_id, a.hit, a.voted_count, a.reply_count, a.reg_date from ( ";

4. $sql.= " ) as a, users b where a.user_id=b.userid ";

3,4번은 조인한건가요? 어떤식으로 구성됫는지 설명해주실수 있을까요?


(너무 많은 질문이네요.... 제송합니다..너무 염치가 없네요.. 인터넷 서핑도 해봤는데... 몇개만 건지고 이것들은 도저히 찾을 수가 없어서 질문을 올릴수 밖엣......)

 다음글 Tutorial 따라하는데 news/ 호출할때 &...
 이전글 프로시저 호출 질문 드려요~~~ (2)

댓글

kaido / 2015/08/31 10:02:23 / 추천 0
음...

일단 1번 부터 4번은 전부 mysql 사용법과 관련되어 있습니다.

mysql 사용법을 처음부터 공부를 하셔야 할 것 같습니다.

힌트로는 서브쿼리 관련으로 찾아 보세요.
모숭이 / 2015/08/31 18:16:57 / 추천 0
mysql은 기본거 밖에 몰라서..ㅋㅋ.... 감사합니다! 힌트까지 주시공