새로운 글의 개수 코멘트 개수 알아내기 정보
새로운 글의 개수 코멘트 개수 알아내기본문
팁에 적기가 미안하군요.
그저 오늘 나스카님이 보내주신 소스를 보다가 글을 적습니다.
special thanks for nasca <--- (기분 푸시라고 ^^)
그냥 최신글 개수만.. 가져오다가.. 글과 코멘트를 분리할 생각을 한번도 안해봤다는게 참
우습습니다.
그러다 심심풀이로... 그냥 DB를 뒤비적 거리다가.. sql 코드 하나 적었습니다.
$sql2 = " select * from g4_board_new where bo_table = '$row[bo_table]' and wr_id=wr_parent and bn_datetime >= '$intime'";
즉...
g4_board_new 에서.. (이건 새글의 링크를 가지고 있는 테이블입니다.)
가지고 있는 시간을 가지고.. 글의 개수와...
wr_id=wr_parent <----------- 글의 개수 구하기
wr_id<>wr_parent <---------- 코멘트의 개수 구하기
를 사용해서.. 나타내주는것이지요.
전반적으로 이쪽으로 계속 탐구를 하시는 플록님과
저에게 오늘 쪽지를 보내주신 나스카님에게 감사합니다.
예전 방식보다는 조금 빠르다는것 밖에.. 즉 제가 밑에 코딩해 둔것은 조금 느린듯 합니다.
그저.. 적어둡니다.
참고하실분만.. 참고하시고.. ^^;;
그누를 파악하는게 가장 먼저 우선시 되어야 되는데..
필요할때만 뒤적거리다 보니.. 흐흐 ^^;; 코딩의 막노동이 심하군요..
function group_menu2($skin_dir="",$m_gr_id="") {
global $g4;
global $gr_id;
global $bo_table;
if($m_gr_id=="") $m_gr_id = $gr_id;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/group_menu/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/group_menu/basic";
$m_list = array();
$intime = date("Y-m-d H:i:s", time() - (int)(3600 * 24));
$sql = "select bo_table, bo_subject from $g4[board_table] where gr_id = '$m_gr_id' and bo_10 > 0 order by bo_10";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$sql2 = " select * from g4_board_new where bo_table = '$row[bo_table]' and wr_id=wr_parent and bn_datetime >= '$intime'";
$sql3 = " select * from g4_board_new where bo_table = '$row[bo_table]' and wr_id<>wr_parent and bn_datetime >= '$intime'";
$m_count =mysql_num_rows(sql_query($sql2));
$m_count2 =mysql_num_rows(sql_query($sql3));
if ($m_count > 0 and $m_count2 >0 ) $m_tmp = ' (글:'.$m_count.' 코:'.$m_count2.')';
if ($m_count > 0 and $m_count2 == 0 ) $m_tmp = ' (글:'.$m_count.')';
if ($m_count == 0 and $m_count2 >0 ) $m_tmp = ' (코:'.$m_count2.')';
$m_list[$i][bo_subject] = $row[bo_subject].$m_tmp;
$m_list[$i][bo_table] = $row[bo_table];
if($m_list[$i][bo_table] == $bo_table) $m_list[$i][bo_subject] = '<b>'.$m_list[$i][bo_subject];
$m_tmp ="";
}
ob_start();
include "$latest_skin_path/menu.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
그저 오늘 나스카님이 보내주신 소스를 보다가 글을 적습니다.
special thanks for nasca <--- (기분 푸시라고 ^^)
그냥 최신글 개수만.. 가져오다가.. 글과 코멘트를 분리할 생각을 한번도 안해봤다는게 참
우습습니다.
그러다 심심풀이로... 그냥 DB를 뒤비적 거리다가.. sql 코드 하나 적었습니다.
$sql2 = " select * from g4_board_new where bo_table = '$row[bo_table]' and wr_id=wr_parent and bn_datetime >= '$intime'";
즉...
g4_board_new 에서.. (이건 새글의 링크를 가지고 있는 테이블입니다.)
가지고 있는 시간을 가지고.. 글의 개수와...
wr_id=wr_parent <----------- 글의 개수 구하기
wr_id<>wr_parent <---------- 코멘트의 개수 구하기
를 사용해서.. 나타내주는것이지요.
전반적으로 이쪽으로 계속 탐구를 하시는 플록님과
저에게 오늘 쪽지를 보내주신 나스카님에게 감사합니다.
예전 방식보다는 조금 빠르다는것 밖에.. 즉 제가 밑에 코딩해 둔것은 조금 느린듯 합니다.
그저.. 적어둡니다.
참고하실분만.. 참고하시고.. ^^;;
그누를 파악하는게 가장 먼저 우선시 되어야 되는데..
필요할때만 뒤적거리다 보니.. 흐흐 ^^;; 코딩의 막노동이 심하군요..
function group_menu2($skin_dir="",$m_gr_id="") {
global $g4;
global $gr_id;
global $bo_table;
if($m_gr_id=="") $m_gr_id = $gr_id;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/group_menu/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/group_menu/basic";
$m_list = array();
$intime = date("Y-m-d H:i:s", time() - (int)(3600 * 24));
$sql = "select bo_table, bo_subject from $g4[board_table] where gr_id = '$m_gr_id' and bo_10 > 0 order by bo_10";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$sql2 = " select * from g4_board_new where bo_table = '$row[bo_table]' and wr_id=wr_parent and bn_datetime >= '$intime'";
$sql3 = " select * from g4_board_new where bo_table = '$row[bo_table]' and wr_id<>wr_parent and bn_datetime >= '$intime'";
$m_count =mysql_num_rows(sql_query($sql2));
$m_count2 =mysql_num_rows(sql_query($sql3));
if ($m_count > 0 and $m_count2 >0 ) $m_tmp = ' (글:'.$m_count.' 코:'.$m_count2.')';
if ($m_count > 0 and $m_count2 == 0 ) $m_tmp = ' (글:'.$m_count.')';
if ($m_count == 0 and $m_count2 >0 ) $m_tmp = ' (코:'.$m_count2.')';
$m_list[$i][bo_subject] = $row[bo_subject].$m_tmp;
$m_list[$i][bo_table] = $row[bo_table];
if($m_list[$i][bo_table] == $bo_table) $m_list[$i][bo_subject] = '<b>'.$m_list[$i][bo_subject];
$m_tmp ="";
}
ob_start();
include "$latest_skin_path/menu.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
추천
1
1
댓글 1개
펑션입니다.
펑션에 애정이 쏠리는 이유는... 홍홍~*
하나 하나 자주 쓰이는 내용을 정리해서
펑션으로 만들어 주신다는 것은,
뭐랄까...
좀 더 앞을 내다 보시는 것 같습니다.
사실 단순한 카운트만 필요했다면,
이미 말씀 하셨듯이 최근게시물(g4_board_new)만 이용하면
아주 가볍게 구동이 가능합니다만...
문제는 바로 그 카테고리라는 녀석이었습니다.(이 놈의 카테고리를 기냥...)
고생하셨습니다.
펑션에 애정이 쏠리는 이유는... 홍홍~*
하나 하나 자주 쓰이는 내용을 정리해서
펑션으로 만들어 주신다는 것은,
뭐랄까...
좀 더 앞을 내다 보시는 것 같습니다.
사실 단순한 카운트만 필요했다면,
이미 말씀 하셨듯이 최근게시물(g4_board_new)만 이용하면
아주 가볍게 구동이 가능합니다만...
문제는 바로 그 카테고리라는 녀석이었습니다.(이 놈의 카테고리를 기냥...)
고생하셨습니다.