파일 한번에 불러오기.. 정보
파일 한번에 불러오기..본문
//전체 파일 불러오기
$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;
요 부분만 설정 하게 되면 겔러리 게시판이나 최신글 같은 경우 쿼리 한번으로 불러들이는..
실용성은 고수님들께서 판단해주심이..^^
제가 while문을 놓쳤네요. ^^
list.php 파일과 latest.lib.php 파일에서 위에 내용을 적용할수 있습니다.
그대신 get_list() 요넘에서 get_file() 요넘을 view.php파일에서만 호출하도록 제어 해야 하는..^^
또 공지 사항은 아직까지 get_file()을 호출해야 하지만요..ㅋㅋ
수일내에 해결방안이 생기겠죠..^^
게시판 테이블과 첨부 파일과 join하는 형태까지 발전해야겠군요. ^^