This is SQL-Server specific:

http://vyaskn.tripod.com/hierarchies_in_sql_server_databases.htm

If you want some general discussions on the topic google for
celko   and trees or hierarchical or nested sets

HTH

Dick

On Jun 1, 2004, at 11:22 PM, Paul Wilson wrote:

> I'm trying to build a dynamic hierarchical navigation system using thew
>  following table structure
>
>  ID NAME PARENT_ID
>  1 category1 0
>  2 category1_1 1
>  3 category1_2 1
>  4 category1_1_1 2
>  5 category1_1_2 2
>  6 category2 0
>  7 category3 0
>
>  I would like to be able to do some sort of recursive process and put
>  this information into a structure to output to a page.
>
>  i.e.
>
>  category1
>  category1.category1_1
>  category1.category1_2
>  category1.category1_1.category1_1_1
>  category1.category1_1.category1_1_2
>  category2
>  category3
>
>  I've got the following code but I'm getting stuck on the recursive
>  bit.....
>
>  <cfset startpoint = 0>
>  <cfset tree = StructNew()>
>
>  <cfset getlevel=getchildren(startpoint)>
>
>  <cffunction name="getchildren">
>  <cfargument name="parentID">
>  <cfset var qry_tree="">
>
>  <cfquery datasource="#application.dsn#" name="qry_tree">
>  SELECT * FROM test
>  WHERE Parent_ID  = #arguments.parentid#
>  </cfquery>
>
>  <cfoutput>
>  <cfloop query="qry_tree">
>
>  <cfset name2="category" & currentrow>
>  <cfset tree["category#currentrow#"] =
>  qry_tree.name>
>
>  </cfloop>
>  </cfoutput>
>
>  </cffunction>
>
>  <cfdump var="#tree#">
>
>  Any advice on how to build the hierarchical structure? Would a CFC be
>  better?
>
>  Thanks in advance.....
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to