Example function is part of an Url Redirection app ie bit.ly or tinyurl.com

Goal of function is to create a remote procedure that I can call via 
ajax/jquery to get the url that a redirect points to. I want the results 
returned as a structure in json format.  

Is this ok? Or am I missing something about variable scoping or any other 
best practices? 

Arguments are 'domain' and 'subFolder', ie 'bit.ly' and 'QW67RTY' if the 
shortened url is bit.ly/QW67RTY



  <cffunction name="redirectLookup" hint="looks up a requested url" 
returntype="struct" output="no"  access="remote" returnformat="json">
  
    <cfargument name="domain" type="string" required="true" default="" 
hint="root domain" />
    <cfargument name="subFolder" type="string" required="true" default="" 
hint="subFolder" />
    
    <cfset redirectLookupResults=StructNew()>
    <cfset redirectLookupResults.error = 0>
    <cfset redirectLookupResults.redirectURL = "">
    <cfset redirectLookupResults.redirectID = "">
    <cfset redirectLookupResults.redirectStatus = "">
  
     <cfquery name="redirectLookup" datasource="dbRedirects" maxRows=1 >
      SELECT redirectURL, redirectID, redirectStatus
      FROM tbl_redirects
      WHERE (redirectDomain = <cfqueryparam value="#arguments.domain#">) 
and (redirectSubFolder = <cfqueryparam value="#arguments.subFolder#">) 
    </cfquery>
  
    <cfset redirectLookupResults.redirectURL = 
"#redirectLookup.redirectURL#">
    <cfset redirectLookupResults.redirectID = "#redirectLookup.redirectID#">
    <cfset redirectLookupResults.redirectStatus = 
"#redirectLookup.redirectStatus#">

    <cfsetting showdebugoutput="false" />

    <cfreturn redirectLookupResults>
     
  </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