<?php
$id = $_REQUEST['id'];
if(empty($id)) $id=0;
$query = "select id, substring_index(getpath_v2(id),'|',-1) as path
from gubun_tree_v2 where id=$id"; //
$result=mysqli_query($dbi,$query);
if (mysqli_errno($dbi)) { echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
$matched=mysqli_fetch_assoc($result);
$query = "select a.id,a.parent,a.sub_seq,a.name,a.linked_num,@path:=getpath_v2(a.id),
@temp:=substring_index(substring_index(@path,'|',2),'|',-1) as pre_ord,
(char_length(@temp)-char_length(replace(@temp,'.','')) + 1) as depth,
substring_index(@path,'|',-1) as path
,count(b.id) as sub_cnt
from gubun_tree_v2 a
left join gubun_tree_v2 b on a.id=b.parent
where a.id<>0 and a.parent in (".$cur_path.")
group by a.id
order by pre_ord"
;
$result=mysqli_query($dbi,$query);
if (mysqli_errno($dbi)) { echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
$prev=1; $i=0;
while ( $matched = mysqli_fetch_assoc($result) ) {
$set[] = $matched;
if ($id == $matched[id]) $cur_row = $matched;
if ( strpos(','.$cur_path.',',$matched[parent]) !== false) {
$per_parent_rows[$matched[parent]][] = $matched;
}
$i=$i+1;
}
?>
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"