Yes, I did this in each case statement.

<cfif url.sortby contains "DESC"> DESC</cfif>

Also the expression for the cfswitch need to be modified to this

<cfswitch expression="#ListFirst(url.sortby,',')#">

then I add that to the url sort variable like this.

sortby=categoryname,DESC

It's that simple

-- 
Wil Genovese

One man with courage makes a majority.
-Andrew Jackson

A fine is a tax for doing wrong. A tax is a fine for doing well. 



Vince Collins wrote:
> Thanks Wil,
>
> That suggestion works.  However, in an example of a query with 10 
> columns and assuming you want to allow desc and asc, does anyone  have a 
> more conscience way other than 20 cfcase statements?
>
> I thought about just checking for the existence of the semicolon in the 
> sort variable being passed.  If it exists, ignore it and default the 
> sort.  But...then I'd still be exposing the actual database field name 
> which as you say, is a not desirable.
>
> I haven't attempted to use a framework yet.  Do these 
> already/automagically account for this?  Does anyone else have another 
> way of dealing with this?
>
>
>
>   
>> I like to use a cfswitch if there are more than two sort columns.
>>
>> I pass something like sort=name or sort=date etc in the URL.  My table 
>> columns are never this simply named so I don't have any conflicts.
>>
>> Then in the cfswitch statement I have something like this
>>
>> <cfswitch expression"#url.sort#">
>>     <cfcase value="name">
>>           order by table.user_name
>>     <cfcase>
>>     <cfcase value="date">
>>           order by table.lastlogin_date
>>     <cfcase>
>> ..
>> ..
>> ..
>> </cfswitch>
>>     
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288616
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to