Hagan, Ryan Mr (Contractor ACI) wrote: > > I personally like this solution quite a bit. I know it has performance > issues, but I've never noticed any significant impact on server response, > even under heavy load.
I think it is an ugly workaround. SQL is a set oriented language and the best way to use that is by getting the whole set at once. Furthermore it is important to keep in mind that your solution does not guarantee to return the same order every time. > First and foremost, we can't run queries inside of <cfscript> tags. Bummer. Declare your cfquery as a <cffunction>. > Second, even if the query issue were resolved (and if you've got ideas for > work-arounds, I'd love to hear them), you've now got variable scope issues. > A variable declared in a CFMX page is global (correct me if I'm wrong) to > the entire page, even inside of functions. Wouldn't <cfset var myquery=...> solve that? > So where does that leave us? I'd be interested in some info on CFMX CFCs. > Can I use recursion in a CFC function? Sure you can. > A lot of problems that are solved with recursion can be rewritten using > while loops. For this particular problem, though, I've not been able to > come up with a non-recursive solution (assuming the above table structure). > Can anyone help me here? So don't use that table structure :-) Use a nested set model, or use a 2 table model where one table holds complete trees in an XMLData field (which you only need to edit when a new element is inserted) and one holds individual messages but with an FK to the table that holds the complete trees in XML. I usually prefer the first solution, but in some cases the latter solution allows you to offload the whole thing to the client and let the client figure it out using XSLT. Something like: http://spike.oli.tudelft.nl/jochemd/test/tree/test.xml Jochem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4