recordcount is 0 or not.
<cfcomponent>
<cffunction name="myFunction" access="public"
returntype="query">
<cfset myResult="foo">
<!--- Will return no records --->
<cfquery name="qryTest"
datasource="#application.qryDSN#">
Select *
From tblArticle
Where Homepage=2
</cfquery>
<cfreturn qryTest>
</cffunction>
</cfcomponent>
Junk.cfm
<cfobject component="test" name="objtest">
<cfinvoke component="#objtest#" method="myFunction"
returnvariable="qryarticle">
<cfif qryArticle.recordcount EQ 0>
<cfdump var="#objtest#">
</cfif>
Page results
component
<http://localhost/CFIDE/componentutils/CFCExplorer.cfc?method=getcfcinhtml&n
ame=dreamcatcher.test> dreamcatcher.test
MYFUNCTION
function myFunction
Arguments:
none
Return Type:
query
Roles:
Access:
public
Output:
Yes
_____
From: Dain Anderson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 01, 2004 3:16 PM
To: CF-Talk
Subject: Re: Is an empty query object still a "good" query object?
Jeff Small wrote:
> But useful, in sofar as you could build a little check <cfif
> myQuery.recordcount GT 0> and it would work...
Correct me if I'm wrong, but when an empty query object is returned from
a CFC, and then you check for RecordCount, it throws an error stating
"recordcount does not exist for 'x' query". This isn't the case with a
normal CFQUERY.
The workaround I've used is this (from within a CFC):
<CFFUNCTION NAME="getValues" RETURNTYPE="query">
<CFQUERY NAME="getItems" DATASOURCE="#Request.Datasource#">
SELECT *
FROM myTable
WHERE Some_Value = '#Arguments.SomeValue#'
</CFQUERY>
<CFIF NOT getValues.RecordCount>
<CFSET getValues = QueryNew(getValues.ColumnList)>
</CFIF>
<CFRETURN getValues>
</CFFUNCTION>
This correctly returns an empty query object. I'm not sure why CFCs do
this, but this is what I've found at any rate.
-Dain
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

