Ask a Question related to Coldfusion Database Access, Design and Development.
-
Stanley_G #1
Need help with building a custom query
Hi everybody.
How can I create a custom query based on argument passed to CFC?
Here is a sample code:
<cffunction name="get_all_brands" access="remote" returntype="query">
<cfargument name="show_hidden" type="boolean" required="no" default="false"
/>
<cfset var all_brands_qry = "" />
<cfif show_hidden is true>
<cfquery name="all_brands_qry" datasource="cupoint">
SELECT dbo.cupoint_item_brand.intBrandID as BrandID,
dbo.cupoint_item_brand.vchBrandName as BrandName,
dbo.cupoint_item_brand.bitActive as BrandActive
FROM dbo.cupoint_item_brand
</cfquery>
<cfelse>
<cfquery name="all_brands_qry" datasource="cupoint">
SELECT dbo.cupoint_item_brand.intBrandID as BrandID,
dbo.cupoint_item_brand.vchBrandName as BrandName,
dbo.cupoint_item_brand.bitActive as BrandActive
FROM dbo.cupoint_item_brand
WHERE dbo.cupoint_item_brand.bitActive = 1
</cfquery>
</cfif>
<cfreturn all_brands_qry />
</cffunction>
Is there a way to filter argument "show_hidden" through cfif and just add
"WHERE dbo.cupoint_item_brand.bitActive = 1" to the first portion of SQL query?
I should be easy. I come from ASP bg and just need a quick tip.
Thank you.
SG
Stanley_G Guest
-
Building a custom dialog look...
I want to build a control that alows a custom dialog border type of look. I'm implementing it now with a 3 x 3 table. Corner images and repeateable... -
RH9 - Building custom kernel
Guys, I'm pretty new to this game.. so here's what I'm trying to do.. I have a stock standard RH9 (Shrike running 2.4.20-8) and I'd like Crypto... -
Looking for a tutorial on building custom controls
Any ideas? -- Thanks, Billy -
Custom Filters building
Does anyone know where you can find a guide to building custom filters? I have a stack of books but i can't find anywhere that tells what each block... -
Building Custom Controls
Hello, Is is possible to control a custom control like the asp.net server controls without making it into an assembly? For example, if my... -
CFDEBUG #2
Re: Need help with building a custom query
You could do
<cffunction name="get_all_brands" access="remote" returntype="query">
<cfargument name="show_hidden" type="boolean" required="no" default="false" />
<cfquery name="all_brands_qry" datasource="datasourcename">
SELECT dbo.cupoint_item_brand.intBrandID as BrandID,
dbo.cupoint_item_brand.vchBrandName as BrandName,
dbo.cupoint_item_brand.bitActive as BrandActive
FROM dbo.cupoint_item_brand
<cfif not show_hidden>
WHERE dbo.cupoint_item_brand.bitActive = 1
</cfif>
</cfquery>
<cfreturn all_brands_qry />
</cffunction>
CFDEBUG Guest



Reply With Quote

