User Guide
52 Using the Flex Data Service Assembler
Creating the count method
The count method returns the number of records that would be returned by the fill method.
The return type of the
count method is numeric. It appears as follows:
<cffunction name="count" output="no"
returntype="samples.contact.Contact[]" access="remote">
<cfargument name="param" type="string" required="no">
<cftry>
<cfset dao = CreateObject("component", "samples.contact.ContactDAO")>
<cfif structKeyExists(arguments, "param")>
<cfreturn dao.count(param=arguments.param)>
<cfelse>
<cfreturn dao.count()>
</cfif>
<!--- If the SQL failed, mark this change with the error. --->
<cfcatch type="database">
<cfset msg = "Error during count: " & cfcatch.queryError &
". SQL was :" & cfcatch.sql>
<cfset co.fail(msg)>
</cfcatch>
<!--- If anything else happened, mark this change with the error. --->
<cfcatch type="any">
<cfset co.fail(cfcatch.message & " " & cfcatch.detail)>
</cfcatch>
</cftry>
</cffunction>