여분필드를 이용한 최신글 추출
본문
https://gnustudy.com/bbs/board.php?bo_table=skin_latest&wr_id=23
이팁을 사용해 추출을 하는건 알겠는데요
여분필드를 만약 1~8부터 사용했을때 해당필드가 선택되면 추출하려고 합니다
저기는 필드1마다 일일히 해야하는 방식같아서 고수님들께 여쭤봅니당...
답변 2
latest_main 함수의 마지막 변수인 options에다 필드명을 array로 넘겨주시고
내부에서 쿼리를 수정하시면 될것 같습니다.
호출
latest_main("basic", notice, 5, 25, 1, array('wr_1', 'wr_2', 'wr_3'));
함수
function latest_main($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
//... 생략
if(!G5_USE_CACHE || $cache_fwrite) {
$list = array();
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
$board = sql_fetch($sql);
$bo_subject = get_text($board['bo_subject']);
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$sql_options = "";
foreach($options as $option){
$sql_options .= " and ".$option." = '1' ";
}
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 and ".$sql_options." order by wr_num limit 0, {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
}
if($cache_fwrite) {
$handle = fopen($cache_file, 'w');
$cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".sql_escape_string($bo_subject)."';\n\$list=".var_export($list, true)."?>";
fwrite($handle, $cache_content);
fclose($handle);
}
}
//... 생략
}
Where ..and '1' in ( wr_1, wr_2, ..., wr_8)