파일 한번에 불러오기.. > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

파일 한번에 불러오기.. 정보

파일 한번에 불러오기..

본문

//전체 파일 불러오기
$wr_id_in = "";
for ($i=0; $i<count($list); $i++){
 if($i) $wr_id_in .= ", ";
 $wr_id_in .= $list[$i]['wr_id'];
 // 게시물별 파일게수 카운팅
 $list[$i][file]['count'] = 0;
 //파일 넘버링
 $num[$list[$i]['wr_id']] = $i;
}

// 파일 쿼리문
$file_sql = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id in ($wr_id_in) order by bf_no ";
$file_result = sql_query($file_sql);
while ($row = sql_fetch_array($file_result))

 // 넘버링
 $i = $num[$row['wr_id']];
 $no = $row[bf_no];
    $list[$i]['file'][$no]['href'] = "./download.php?bo_table=$bo_table&wr_id=$wr_id&no=$no" . $qstr;
    $list[$i]['file'][$no]['download'] = $row[bf_download];
    $list[$i]['file'][$no]['path'] = "$g4[path]/data/file/$bo_table";
    $list[$i]['file'][$no]['size'] = get_filesize($row[bf_filesize]);
    $list[$i]['file'][$no]['datetime'] = $row[bf_datetime];
    $list[$i]['file'][$no]['source'] = $row[bf_source];
    $list[$i]['file'][$no]['bf_content'] = $row[bf_content];
    $list[$i]['file'][$no]['content'] = get_text($row[bf_content]);
    $list[$i]['file'][$no]['view'] = view_file_link($row[bf_file], $row[bf_width], $row[bf_height], $list[$i][file][$no][content]);
    $list[$i]['file'][$no]['file'] = $g4_file[$f][bf_file];
    $list[$i]['file'][$no]['image_width'] = $row[bf_width] ? $row[bf_width] : 640;
    $list[$i]['file'][$no]['image_height'] = $row[bf_height] ? $row[bf_height] : 480;
    $list[$i]['file'][$no]['image_type'] = $row[bf_type];
 $list[$i]['file'][$no]['img_src'] = "$g4[path]/data/file/$bo_table/".urlencode($row[bf_file]);
    $list[$i]['file']['count']++;
}

추천
1

댓글 6개

get_file() 은 게시물 하나당 한번씩 쿼리가 날라가는 반면

위소스는 쿼리를 하나로 만들어 목록이 완료된후 한번에 날리는 형식입니다.

게시물 목록을 작성시 get_list() 안에서

 if($i) $wr_id_in .= ", ";
 $wr_id_in .= $list[$i]['wr_id'];
 // 게시물별 파일게수 카운팅
 $list[$i][file]['count'] = 0;
 //파일 넘버링
 $num[$list[$i]['wr_id']] = $i;

요 부분만 설정 하게 되면 겔러리 게시판이나 최신글 같은 경우 쿼리 한번으로 불러들이는..

실용성은 고수님들께서 판단해주심이..^^
그건 설정 하기 나름 이죠..^^
list.php 파일과 latest.lib.php 파일에서 위에 내용을 적용할수 있습니다.
그대신 get_list() 요넘에서 get_file() 요넘을 view.php파일에서만 호출하도록 제어 해야 하는..^^
공지 사항은 아직까지 get_file()을 호출해야 하지만요..ㅋㅋ
수일내에 해결방안이 생기겠죠..^^
전체 6 |RSS
그누4 팁자료실 내용 검색
  • 개별 목록 구성 번호 제목 작성자 작성일 추천 조회
  • 게시물이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT