소스 파일 : /view/view_contents_db_qry.php (2017-10-27)     소스 설명 : (용어보기) ... 작성중
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
<?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;
		}

?>


Copyrightⓒ written by 차재복 (Cha Jae Bok)
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"