On Thu, Jul 5, 2012 at 10:26 AM, Jason King <[email protected]> wrote:
> My goal is to take two variables, domain, subFolder, and apply them as
> arguments to a function that will run a query and return either a 0/1
> result (yes, no)
>
You could return a boolean instead of numbers indicating true or false.
>
> <cfcomponent displayname="dns" hint="component for domain names">
>
> <cffunction name="dnsLookup" hint="looks up a requested url"
> returntype="query">
>
You'd only use returntype="query" if you want to return the query object.
Now, if I want to use that function, can I run it directly in an
> if/then statement?
Yes.
> Or do I need to invoke it first, then use the
> results in an if/then statement?
>
No.
>
> <cfinvoke component="dns" method="dnsLookupRecordCount"
> returnvariable="dnsRecordCount" domain="#domain#"
> subFolder="#subFolder#" />
>
> <cfif dnsLookupRecordCount gte 1> do work </cfif>
>
If this is a function you're going to use throughout your app you'll want
to instantiate the CFC once when the app loads (in OnApplicationStart in
Application.cfc for example) and then call the function as needed. (Another
general rule -- I tend to only use cfinvoke if I need the capability to
call the method name as a variable.)
<cfset Application.myCFC = CreateObject("component", "path.to.the.CFC") />
Then in your code:
<cfset dnsExists = Application.myCFC.dnsLookup(foo, bar) />
--
Matthew Woodward
[email protected]
http://blog.mattwoodward.com
identi.ca / Twitter: @mpwoodward
Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en