I have a basic function that will take a userID and check if an APIKey has 
been issued to it. Just want to return a simple true/false. Don't need any 
advanced error reporting. 

Is name 'checkExistsAPIKey' a good name? 

I've considered checkAPIKeyExists, isDefinedAPIKey, APIKEYisDefined, etc. 

The following seems simple enough. It takes the USERID as an argument, and 
if numeric (userID's are numeric) checks it against the proper database. If 
it has a match, it flags the returnvalue as true. If it isn't numeric, it 
will be false. If it's numeric, but no match.. false as well. 

I don't want to overcomplicate what seems what should be a simple 
true/false function. 

Thoughts? 


  <cffunction name="checkExistsAPIKey" returntype="boolean" output="no" 
access="remote" returnformat="json">
 
    <cfargument name="userID" type="string" required="true" default="" 
hint="user email" />
    
    <cfset checkExistsAPIKeyResults = false>
    
    <cfif isNumeric(arguments.userID)>
      
      <cfquery name="checkExistsAPIKey" datasource="dbAPI" maxRows="1" >
  
        SELECT keyID
        FROM tbl_apiKey
        WHERE userID = <cfqueryparam value="#arguments.userID#">
  
      </cfquery>
  
      <cfif checkExistsAPIKey.recordcount gte 1>
        <cfset checkExistsAPIKEYResults = true>
      </cfif>

    </cfif>
  
    <cfsetting showdebugoutput="false" />

    <cfreturn checkExistsAPIKEYResults> 

</cffunction

-- 
-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Open 
BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to