why adverse to the 2 function route?  they seem to serve 2 purposes...

getAllUsers()
getUserByID(userID)

but you could easily do:

<cffunction name="getUsers" returntype="query" access="remote">
<cfargument name="userID" type="numeric" required="no" />

<cfset var qGetUsers = "" />

<cfquery name="qGetUsers" datasource="#application.ds#">
     SELECT
          (columns here)
     FROM
           Users
     WHERE
            Active = '1'
            <cfif structKeyExists(arguments, 'userID')>
                 AND Users.UserID = <cfqueryparam
value="#arguments.userID#" cfsqltype="cf_sql_integer" />
             </cfif>
</cfquery>

<cfreturn qGetUsers />
</cffunction>

On 7/12/07, Steve Sequenzia <[EMAIL PROTECTED]> wrote:
> I am not sure if this is possible but here is what I am trying to do.
>
> I have a function that queries the database (MSSQL) for all users:
>
>         <cffunction name="getUsers" returntype="query" access="remote">
>
>         <cfquery name="queryUsers" datasource="#application.ds#">
>
>             SELECT userID, userType, userAccessLevel, userName, firstName, 
> lastName
>             FROM Users
>             WHERE active = '1'
>
>         </cfquery>
>
>         <cfreturn queryUsers>
>
>     </cffunction>
>
> I was going to add an argument to it for userID and change the where clause 
> to (WHERE active = '1' and userID = '#arguments.userID#'). That should work 
> fine but what I would like to do is still use the same function to retrive 
> all the users not just the one with the selected userID.
>
> I would like to keep it all in the same function without having to use an if 
> clause.
>
> The end result would be that if I pass the userID to it I get back a query 
> with just the one record that matches the userID but if I do not pass the 
> userID to it, it returns all of the records.
>
> Like I said, I am not sure if this is even possible.
>
> Any help on this would be great.
>
> Thanks in advance.
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

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

Reply via email to