그누보드 게시판 관리자페이지에 보면,
해당게시판의 카운트를 조절하는 부분이 있습니다.
기존방식으로 하면 다소 느릴 수 있는 것을 최적화 해보았습니다.
파일 : /adm/board_form_update.php
라인 : 207 라인근처 ( // 글수 조정 ) 주석 아래입니다.
변경전
// 글수 조정
if ($proc_count) {
// 원글을 얻습니다.
$sql = " select wr_id from $g4[write_prefix]$bo_table where wr_is_comment = 0 ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
if ($proc_count) {
// 원글을 얻습니다.
$sql = " select wr_id from $g4[write_prefix]$bo_table where wr_is_comment = 0 ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
// 코멘트수를 얻습니다.
$sql2 = sql_query(" select count(*) as cnt from $g4[write_prefix]$bo_table where wr_parent = '$row[wr_id]' and wr_is_comment = 1 ");
$row2 = sql_fetch_array($sql2);
$sql2 = sql_query(" select count(*) as cnt from $g4[write_prefix]$bo_table where wr_parent = '$row[wr_id]' and wr_is_comment = 1 ");
$row2 = sql_fetch_array($sql2);
sql_query(" update $g4[write_prefix]$bo_table set wr_comment = '$row2[cnt]' where wr_id = '$row[wr_id]' ");
echo ".";
if ($i%50==0) { echo "<br/>"; flush(); }
}
mysql_free_result($result);
}
echo ".";
if ($i%50==0) { echo "<br/>"; flush(); }
}
mysql_free_result($result);
}
변경후
// 글수 조정
if ($proc_count) {
// 원글을 얻습니다.
$sql = " select a.wr_id,count(b.wr_parent) as cnt from $g4[write_prefix]$bo_table a, $g4[write_prefix]$bo_table b where a.wr_id=b.wr_parent and a.wr_is_comment=0 group by a.wr_id";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
if ($proc_count) {
// 원글을 얻습니다.
$sql = " select a.wr_id,count(b.wr_parent) as cnt from $g4[write_prefix]$bo_table a, $g4[write_prefix]$bo_table b where a.wr_id=b.wr_parent and a.wr_is_comment=0 group by a.wr_id";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
sql_query(" update $g4[write_prefix]$bo_table set wr_comment = '$row[cnt]' where wr_id = '$row[wr_id]' ");
echo ".";
if ($i%50==0) { echo "<br/>"; flush(); }
}
mysql_free_result($result);
}
echo ".";
if ($i%50==0) { echo "<br/>"; flush(); }
}
mysql_free_result($result);
}
댓글 9개
게시글 목록
| 번호 | 제목 |
|---|---|
| 34292 | |
| 34279 | |
| 34278 | |
| 34264 | |
| 34251 | |
| 34231 | |
| 34196 | |
| 34184 | |
| 34166 | |
| 34151 | |
| 34143 | |
| 34142 | |
| 34134 | |
| 34132 | |
| 34131 | |
| 34125 | |
| 34093 | |
| 34076 | |
| 34060 | |
| 34031 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기