set aa=new classlist aa.id="id"http://編號的名稱 aa.classname="classname"http://分類名稱 aa.pid="pid"http://父ID名稱 aa.db_name="class"http://表名 list=aa.arrylist()
復制代碼 代碼如下:
<% class classlist private c_id private c_db_name private c_pid private c_classname public property let id(str) c_id = str end property public property let db_name(str) c_db_name = str end property public property let pid(str) c_pid = str end property public property let classname(str) c_classname = str end property dim list() dim i,n Private Sub Class_Initialize()'初始化變量 i=0 n=0 End Sub public function classarry(thisid,pid)'取得下級ID if pid>0 then sql="select * from "&c_db_name&" where "&c_pid&"="&thisid else sql="select * from "&c_db_name&" where "&c_id&"="&thisid end if set rs_c=conn.execute(sql) n=n+1 do while not rs_c.eof list(0,i)=rs_c(c_id)'裝入數組中 list(1,i)=rs_c(c_classname) list(2,i)=n 'n=n+1 i=i+1 thisid=classarry(rs_c(c_id),1)'這里遞歸調用,直到最后一個子類 rs_c.movenext loop n=n-1 rs_c.close end function public function arrylist()'循環出所有根類 set rs_c=conn.execute("select count("&c_id&") from "&c_db_name) lenght=rs_c(0) rs_c.close redim list(2,lenght)'設置數組 set rs1=conn.execute("select "&c_id&" from "&c_db_name&" where "&c_pid&"=0") do while not rs1.eof call classarry(rs1(c_id),0) 'n=1 rs1.movenext loop rs1.close arrylist=list end function end class %>