채택완료
파일을 첨부할 때 g5_board_file 들어가는 것 궁금한게 있습니다.
안녕하세요~
파일을 첨부할 떄 게시판에서 10개, 1개, 0개 등등 설정할 수 있잖아요
근데 db 테이블 확인해보니까
5개를 첨부로 설정해놓고
3번째 파일첨부에 파일을 업로드시키면
g5_board_file 테이블에
g5_board_file
-------
0 빈값
1 빈값
3 3번째파일.jpg
-------------
이렇게 3번째에는 파일이 들어가고 그 위의 번호들이 같이 찍히면서 들어가던데
어떤 원리로 이렇게 들어가는지 궁금합니다...
번호가 더이상 안올라가고 고정된 상태인 거는 update로 하면 되는 것 같은데
3번째에 첨부하면 한번에 (앞 번호)1,2도 같이 뜨는게 어떤식으로 만든건지 궁금합니다..
write_update.php 에서 살펴보긴 했는데 봐도 잘 모르겠습니다..ㅠㅠ
Copy
// 나중에 테이블에 저장하는 이유는 $wr_id 값을 저장해야 하기 때문입니다.for ($i=0; $i<count($upload); $i++){ if (!get_magic_quotes_gpc()) { $upload[$i]['source'] = addslashes($upload[$i]['source']); } $row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "); if ($row['cnt']) { // 삭제에 체크가 있거나 파일이 있다면 업데이트를 합니다. // 그렇지 않다면 내용만 업데이트 합니다. if ($upload[$i]['del_check'] || $upload[$i]['file']) { $sql = " update {$g5['board_file_table']} set bf_source = '{$upload[$i]['source']}', bf_file = '{$upload[$i]['file']}', bf_link = '{$upload[$i]['wr_img1']}', bf_content = '{$bf_content[$i]}', bf_filesize = '{$upload[$i]['filesize']}', bf_width = '{$upload[$i]['image']['0']}', bf_height = '{$upload[$i]['image']['1']}', bf_type = '{$upload[$i]['image']['2']}', bf_datetime = '".G5_TIME_YMDHIS."' where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "; sql_query($sql); } else { $sql = " update {$g5['board_file_table']} set bf_content = '{$bf_content[$i]}' where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "; sql_query($sql); } } else { $sql = " insert into {$g5['board_file_table']} set bo_table = '{$bo_table}', wr_id = '{$wr_id}', bf_no = '{$i}', bf_source = '{$upload[$i]['source']}', bf_file = '{$upload[$i]['file']}', bf_link = '{$upload[$i]['wr_img1']}', bf_content = '{$bf_content[$i]}', bf_download = 0, bf_filesize = '{$upload[$i]['filesize']}', bf_width = '{$upload[$i]['image']['0']}', bf_height = '{$upload[$i]['image']['1']}', bf_type = '{$upload[$i]['image']['2']}', bf_datetime = '".G5_TIME_YMDHIS."' "; sql_query($sql); }} // 업로드된 파일 내용에서 가장 큰 번호를 얻어 거꾸로 확인해 가면서// 파일 정보가 없다면 테이블의 내용을 삭제합니다.$row = sql_fetch(" select max(bf_no) as max_bf_no from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");for ($i=(int)$row['max_bf_no']; $i>=0; $i--){ $row2 = sql_fetch(" select bf_file from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "); // 정보가 있다면 빠집니다. if ($row2['bf_file']) break; // 그렇지 않다면 정보를 삭제합니다. sql_query(" delete from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' ");} // 파일의 개수를 게시물에 업데이트 한다.$row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");sql_query(" update {$write_table} set wr_file = '{$row['cnt']}' where wr_id = '{$wr_id}' "); // 자동저장된 레코드를 삭제한다.sql_query(" delete from {$g5['autosave_table']} where as_uid = '{$uid}' ");//------------------------------------------------------------------------------
|
답변 1개
채택된 답변
+20 포인트
테이블 구조
- NULL 여부는 모든 필드가 NOT NULL이기에 따로 남기지 않습니다.
| Column1) | Type | Default | 설명 | 연결 DB table2) |
|---|---|---|---|---|
bo_table | varchar(20) | 게시판 TABLE | board_table.bo_table | |
wr_id | int(11) | 0 | 게시물번호 | write_table.wr_id |
bf_no | int(11) | 0 | 파일번호 | |
| bf_source | varchar(255) | 파일 원본이름 | ||
| bf_file | varchar(255) | 파일명 | ||
| bf_download | int(11) | 다운로드 수 | ||
| bf_content | text | 파일설명 | ||
| bf_filesize | int(11) | 0 | 파일용량 | |
| bf_width | int(11) | 0 | 첨부파일 폭 | |
| bf_height | smallint(6) | 0 | 첨부파일 높이 | |
| bf_type | tinyint(4) | 0 | 첨부파일 유형 | |
| bf_datetime | datetime | 0000-00-00 00:00:00 | 등록일시 |
답변을 작성하려면 로그인이 필요합니다.
