item_list where 조건으로 특정 column 검색
item_list 클래스로 상품을 가져올 때 특정 컬럼 조건에 맞는 상품만 가져오려는 경우 아래와 같이 처리합니다.
/shop/list.php
$list = new item_list($skin_file, $ca['ca_list_mod'], $ca['ca_list_row'], $ca['ca_img_width'], $ca['ca_img_height']);
$list->where_column('it_region','강원'); #이런식으로 검색하려는 컬럼과 검색 키워드를 넣습니다.
$list->set_category($ca['ca_id'], 1);
$list->set_category($ca['ca_id'], 2);
$list->set_category($ca['ca_id'], 3);
/lib/shop.lib.php : class item_list
#아래와 같은 함수를 작성합니다.
#if조건에 DB에 생성한 column명으로 교체합니다. $this->{컬럼명} <<이부분도 교체합니다.
//g5_shop_item의 특정 column을 where 검색
function where_column($column, $value) {
if ($column == 'parent_it') {
$this->parent_it = $value;
} else if ($column == 'it_day') {
$this->it_day = $value;
} else if($column == 'it_region'){
$this->it_region = $value;
}
}
(* 위 함수는 function set_category 함수 위에 위치시켰습니다.)
#아래와 같은 코드를 추가합니다.(조건 검색 sql)
#아래 코드에서 컬럼명을 수정하시면 됩니다.
if ($this->parent_it || $this->it_day || $this->it_region) {
$where_added_column = array();
if ($this->parent_it) {
$where_added_column[] = " parent_it like '{$this->parent_it}' ";
}
if ($this->it_day) {
$where_added_column[] = " it_day like '{$this->it_day}' ";
}
if ($this->it_region) {
$where_added_column[] = " it_region like '{$this->it_region}' ";
}
$where[] = " ( " . implode(" or ", $where_added_column) . " ) ";
}
(* 위 코드는 'if ($this->ca_id || $this->ca_id2 || $this->ca_id3) {' 코드 위에 위치시켰습니다.)
댓글 5개
게시판 목록
영카트5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 71 | 10년 전 | 7872 | ||
| 70 | 10년 전 | 5642 | ||
| 69 | 10년 전 | 5786 | ||
| 68 | 11년 전 | 11894 | ||
| 67 | 11년 전 | 8073 | ||
| 66 | 11년 전 | 6184 | ||
| 65 | 11년 전 | 6312 | ||
| 64 | 11년 전 | 6623 | ||
| 63 | 11년 전 | 7038 | ||
| 62 | 11년 전 | 10229 | ||
| 61 | 11년 전 | 23163 | ||
| 60 |
xepiesta
|
11년 전 | 4875 | |
| 59 | 11년 전 | 8271 | ||
| 58 | 11년 전 | 9004 | ||
| 57 | 11년 전 | 6683 | ||
| 56 |
|
11년 전 | 7169 | |
| 55 |
|
11년 전 | 6205 | |
| 54 | 11년 전 | 15788 | ||
| 53 |
kiplayer
|
11년 전 | 6656 | |
| 52 | 11년 전 | 7176 | ||
| 51 | 11년 전 | 10053 | ||
| 50 |
|
11년 전 | 5160 | |
| 49 | 11년 전 | 8438 | ||
| 48 | 11년 전 | 6143 | ||
| 47 | 11년 전 | 7210 | ||
| 46 | 11년 전 | 4209 | ||
| 45 | 11년 전 | 8044 | ||
| 44 | 11년 전 | 3924 | ||
| 43 | 11년 전 | 5437 | ||
| 42 | 11년 전 | 8194 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기