I wanted to use count()
function in ColdFusion Query object.
Here is my code and test:
<cfset x = querynew("id,name")>
<cfquery name="y" dbtype="query">
select count(*) as total from x
</cfquery>
<cfoutput>Test1: #y.total#</cfoutput>
<cfset temp = QueryAddRow(x)>
<cfset Temp = QuerySetCell(x, "id", 1)>
<cfset Temp = QuerySetCell(x, "Name", "Vikas")>
<cfquery name="y" dbtype="query">
select count(*) as total from x
</cfquery>
<cfoutput>Test2: #y.total#</cfoutput>
Should I use convert function? Like if total is [enpty string] then result should be 0. Or is there any other best/proper way to do that?