채택완료

다중 게시판 통합 추출 에러

2014-09-18 (목) 18:13:03 4,567

http://sir.co.kr/bbs/board.php?bo_table=g5_tip&wr_id=857&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%EC%97%AC%EB%9F%AC+%EA%B2%8C%EC%8B%9C%ED%8C%90

위 게시물을 참조해 여러 게시판의 최신글을 통합 추출해내게끔 하려고 하는데요,

일단 g4로 되어있는걸 전부 g5로 바꿨더니 잘 되는 듯 보이더라고요.

그런데, 링크가 꼬입니다.

예를 들어.... notice에 1, 2번 글을, qna에 3번 글을 등록하면 순서대로

3 / 2 / 1 순으로 추출은 잘 되는데, bo_table의 id는 전부 qna로 되는 식이에요.

그러니 어떤 글은 링크가 잘 걸리고 어떤 글은 존재하지 않는다고 나오고....

그런데 이게 항상 이런건 아니고 테스트를 해보니까 특정 게시판끼리는 제대로 돌아가더라구요.

그런데 규칙은 잘 모르겠어요;;

말이 좀 복잡하게 쓰이긴 했는데요 ㅠㅠ

아래 코드를 살펴봤을 때 고쳐야할 부분이 있다면 가르쳐주시면 정말 감사하겠습니다.

Copy
<?php function latest_multi($skin_dir = "", Array $bo_tableIds, $rows = 10, $subject_len = 40) {    global $g5;    //static $css = array();    if (!$skin_dir) $skin_dir = 'basic';    if(G5_IS_MOBILE) {        $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;        $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;    } else {        $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;        $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;    } $sql_select = "  "; $list = array(); $sql  = "  select b.gr_id, a.bo_table, a.wr_id, a.wr_parent, a.bn_datetime, b.bo_subject, b.bo_subject  from $g5[board_new_table] a, $g5[board_table] b  where a.bo_table = b.bo_table and a.bo_table in('" . implode("','", $bo_tableIds) . "') and a.wr_id = a.wr_parent  order by a.bn_id desc limit $rows "; $_boardInfo       = array(); $_notExistsBoards = array(); $result = sql_query($sql); foreach ($bo_tableIds as $tableId) {  $board = sql_fetch("select * from {$g5['board_table']} where bo_table = '" . addslashes($tableId) . "'");  if ($board === false) $_notExistsBoards[] = $tableId;  $_boardInfo[$board['gr_id']] = $board; } for ($i = 0; $row = sql_fetch_array($result); $i++) {  $tmp_write_table = $g5['write_prefix'] . $row['bo_table'];  $row2            = sql_fetch("select * from $tmp_write_table where wr_id = '$row[wr_id]'");  $list[$i]        = $row2;  $list[$i]            = get_list($row2, $_boardInfo[$row['gr_id']], $latest_skin_path, $subject_len);  $bo_href[$i]         = $row['bo_table'];  $bo_name[$i]         = $row['bo_subject'];  $list[$i]['wr_date'] = $row2['wr_datetime']; } ob_start(); if ($_notExistsBoards) {  echo join(", ", $_notExistsBoards) . " 게시판이 존재하지 않습니다."; } include "$latest_skin_path/latest.skin.php"; $content = ob_get_contents(); ob_end_clean(); return $content;}?>​
Copy
<? echo latest_multi("basic", array("notice","qna"), 5, 70); ?>
 
|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트

답변에 대한 댓글 1개

감사합니다^^

답변을 작성하려면 로그인이 필요합니다.