[10원짜리 팁] 게시판 합치기
A, B 두개의 게시판을 하나로 합치고 싶은 경우
선택복사 또는 선택이동을 이용해서 할 수도 있지만 이 방법은 게시물이 많은 경우 많은 시간이 필요합니다
단번에 합치는 코드 입니다(첨부화일도 복사합니다)
실행한 후 합쳐진 게시판의 게시판 관리에서 카운트 조정을 한번 해주면 됩니다
testB 게시판 내용을 testA 게시판으로 합치는 예제입니다
합친 후 B게시판은 삭제하던지 지지고 볶던지 맘대로 하시면 됩니다
첨부화일 복사 후 B게시판에서 삭제하려면 unlink 주석풀어서 사용
<?
include "_common.php";
$bo_tableA="testA;
$bo_tableB="testB";
$write_tableA=$g4[write_prefix].$bo_tableA;
$write_tableB=$g4[write_prefix].$bo_tableB;
sql_query("lock tables $write_tableA write,$write_tableB write ", false);
$row=sql_fetch("select max(wr_id) as cnt from $write_tableA");
$plusCnt= $row[cnt] + 100;
echo $write_tableB.'==>'.$write_tableA.'<p>';
echo "<hr>";
sql_query("INSERT INTO $write_tableA (wr_id ,wr_num, wr_reply, wr_parent ,wr_is_comment, wr_comment ,wr_comment_reply ,ca_name,wr_option,wr_subject,wr_content,wr_link1,wr_link2,wr_link1_hit,wr_link2_hit,wr_trackback,wr_hit,wr_good,wr_nogood,mb_id,wr_password,wr_name,wr_email,wr_homepage,wr_datetime,wr_last,wr_ip,wr_1,wr_2,wr_3,wr_4,wr_5,wr_6,wr_7,wr_8,wr_9,wr_10 )
select wr_id+$plusCnt, wr_num-$plusCnt,wr_reply, wr_parent+$plusCnt,wr_is_comment,wr_comment,wr_comment_reply,ca_name,wr_option,wr_subject,wr_content,wr_link1,wr_link2,wr_link1_hit,wr_link2_hit,wr_trackback,wr_hit,wr_good,wr_nogood,mb_id,wr_password,wr_name,wr_email,wr_homepage,wr_datetime,wr_last,wr_ip,wr_1,wr_2,wr_3,wr_4,wr_5,wr_6,wr_7,wr_8,wr_9,wr_10 from $write_tableB ");
sql_query(" unlock tables ", false);
$filePathA=$g4[path].'/data/file/'.$bo_tableA;
$filePathB=$g4[path].'/data/file/'.$bo_tableB;
$dir=@opendir($filePathB);
while($file=readdir($dir)) {
if ($file=='.' || $file=='..') continue;
echo 'file copy : '.$file.'<br>';
@copy($filePathB.'/'.$file, $filePathA.'/'.$file);
// @unlink($filePathB.'/'.$file); 주석풀면 삭제
}
sql_query("update $g4[board_file_table] set bo_table='$bo_tableA', wr_id = wr_id + $plusCnt where bo_table='$bo_tableB'");
?>
<hr>
OK
선택복사 또는 선택이동을 이용해서 할 수도 있지만 이 방법은 게시물이 많은 경우 많은 시간이 필요합니다
단번에 합치는 코드 입니다(첨부화일도 복사합니다)
실행한 후 합쳐진 게시판의 게시판 관리에서 카운트 조정을 한번 해주면 됩니다
testB 게시판 내용을 testA 게시판으로 합치는 예제입니다
합친 후 B게시판은 삭제하던지 지지고 볶던지 맘대로 하시면 됩니다
첨부화일 복사 후 B게시판에서 삭제하려면 unlink 주석풀어서 사용
<?
include "_common.php";
$bo_tableA="testA;
$bo_tableB="testB";
$write_tableA=$g4[write_prefix].$bo_tableA;
$write_tableB=$g4[write_prefix].$bo_tableB;
sql_query("lock tables $write_tableA write,$write_tableB write ", false);
$row=sql_fetch("select max(wr_id) as cnt from $write_tableA");
$plusCnt= $row[cnt] + 100;
echo $write_tableB.'==>'.$write_tableA.'<p>';
echo "<hr>";
sql_query("INSERT INTO $write_tableA (wr_id ,wr_num, wr_reply, wr_parent ,wr_is_comment, wr_comment ,wr_comment_reply ,ca_name,wr_option,wr_subject,wr_content,wr_link1,wr_link2,wr_link1_hit,wr_link2_hit,wr_trackback,wr_hit,wr_good,wr_nogood,mb_id,wr_password,wr_name,wr_email,wr_homepage,wr_datetime,wr_last,wr_ip,wr_1,wr_2,wr_3,wr_4,wr_5,wr_6,wr_7,wr_8,wr_9,wr_10 )
select wr_id+$plusCnt, wr_num-$plusCnt,wr_reply, wr_parent+$plusCnt,wr_is_comment,wr_comment,wr_comment_reply,ca_name,wr_option,wr_subject,wr_content,wr_link1,wr_link2,wr_link1_hit,wr_link2_hit,wr_trackback,wr_hit,wr_good,wr_nogood,mb_id,wr_password,wr_name,wr_email,wr_homepage,wr_datetime,wr_last,wr_ip,wr_1,wr_2,wr_3,wr_4,wr_5,wr_6,wr_7,wr_8,wr_9,wr_10 from $write_tableB ");
sql_query(" unlock tables ", false);
$filePathA=$g4[path].'/data/file/'.$bo_tableA;
$filePathB=$g4[path].'/data/file/'.$bo_tableB;
$dir=@opendir($filePathB);
while($file=readdir($dir)) {
if ($file=='.' || $file=='..') continue;
echo 'file copy : '.$file.'<br>';
@copy($filePathB.'/'.$file, $filePathA.'/'.$file);
// @unlink($filePathB.'/'.$file); 주석풀면 삭제
}
sql_query("update $g4[board_file_table] set bo_table='$bo_tableA', wr_id = wr_id + $plusCnt where bo_table='$bo_tableB'");
?>
<hr>
OK
댓글 9개
takumi22
12년 전
좋은 팁 감사합니다
12년 전
좋은 팁이네요^^
12년 전
감사합니다.
하늘바람구름
12년 전
감사합니다...꼭 필요 했었는데...너무 감사해요...
12년 전
좋은 팁이네용
12년 전
오호 이런방법이.. 감사해요
12년 전
감사합니다^^
bbdbabdbu
12년 전
좋은 팁이네요^^
12년 전
많은 도움이 되었습니다. 감사해요~^^
게시판 목록
그누4 팁자료실
그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.
나누면 즐거움이 커집니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3129 | 12년 전 | 5176 | ||
| 3128 | 12년 전 | 7911 | ||
| 3127 | 12년 전 | 7064 | ||
| 3126 | 12년 전 | 4986 | ||
| 3125 | 12년 전 | 5869 | ||
| 3124 | 12년 전 | 5557 | ||
| 3123 | 12년 전 | 5924 | ||
| 3122 | 12년 전 | 6171 | ||
| 3121 | 12년 전 | 5520 | ||
| 3120 | 12년 전 | 5817 | ||
| 3119 | 12년 전 | 5238 | ||
| 3118 | 12년 전 | 4673 | ||
| 3117 | 12년 전 | 4448 | ||
| 3116 | 12년 전 | 7209 | ||
| 3115 | 12년 전 | 6033 | ||
| 3114 |
생각하는바보
|
12년 전 | 6412 | |
| 3113 |
|
12년 전 | 4822 | |
| 3112 |
|
12년 전 | 5209 | |
| 3111 |
|
12년 전 | 3643 | |
| 3110 |
|
12년 전 | 4083 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기