On Wednesday, May 28, 2003, at 16:42 US/Pacific, jon hall wrote:
> The query to the database is very similar in both cases, the only
> difference being the Where clause in the latter query. The two
> options I see are to build two methods, one called getProducts() and
> another called getProduct(), or build one method called getProduct()
> and give it an optional argument for the product id.
There's nothing wrong with having one method with an optional parameter
which is the ID. If you don't provide it, you get all products. If you
provide ID, you get one product (hopefully!).
I see no problems with this.
<cffunction name="getProduct" returntype="query">
<cfargument name="id" type="string" required="false"/>
...
<cfquery ... name="qResult">
...
<cfif structKeyExist(arguments,"id")>
where id = '#arguments.id#'
</cfif>
</cfquery>
<cfreturn qResult/>
</cffunction>
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community.
http://www.fusionauthority.com/ads.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4