This is driving me nuts. Pretty simple, I have a little custom tag that runs
through a pivot table trying to reach the bottom (categoryID=0) of a category
tree by way of active (bActive=1) categories. The logic is:
It starts by assuming that the tree is bad (goodcat=0).
If it finds a level that is disabled (bActive bit=0), it cfexits, leaving
goodcat=0.
If it makes it to category 0, it flags the caller's goodcat variable as 1 and
cfexits. (Each nest passing its current results to its .caller along the way)
It's throwing a null 500 error and I cannot figure out why; I've commented out
just about every line I can without actually preventing it from nesting and
still throws the error. The pivot table is very simple with only two columns,
here's the data I'm testing with:
CatPivot table, present data:
nCategoryID nParentCatID
289 2337
2337 0
Category table, data: (simplified)
nCategoryID bActive
289 1
2337 1
Code:
<cfparam name="attributes.nCategoryID" default=0>
<cfparam name="nCategoryID" default="#attributes.nCategoryID#">
<cfset caller.goodcat=0>
<cfquery username="#application.dblogin#" password="#application.dbpw#"
name="q1" datasource="#application.datasource#">
SELECT cp.nParentCatID
FROM CatPivot cp
INNER JOIN Category c ON cp.nCategoryID = c.nCategoryID
WHERE cp.nCategoryID = #nCategoryID# AND c.bActive=1
</cfquery>
<cfset goodcat=0>
<cfloop query="q1">
<cfif nParentCatID LT 1>
<cfset caller.goodcat=1>
<cfexit>
</cfif>
<cf_checkpartcat nCategoryID="#nParentCatID#">
<cfset Caller.goodcat=goodcat>
<cfif goodcat GT 0>
<cfexit>
</cfif>
</cfloop>
..And if this can all be done in a single SQL query, by all means please
enlighten me :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331634
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm