JRockFL
asked on
Passing variable to CFC?
I would like to be able to limit the number of news articles. For this particular page, I only want
to display 2.
I'm trying to pass a maxrows variable with the value of 2, but doesn't work. Am I going about this correctly or is there a better way? I'm trying to utilize one stored procedure.
<cfscript>
objNews = createObject("component"," news");
qNews = objNews.GetNews(maxrows = 2);
</cfscript>
<cfcomponent>
<!------------------------ ---------- ---------- ---------- --
GetNews: Returns the news articles
-------------------------- ---------- ---------- ---------- ->
<cffunction name="GetNews">
<cfif IsDefined("maxrows")>
<cfset maxrows = maxrows>
<cfelse>
<cfset maxrows = "-1">
</cfif>
<cfstoredproc procedure="LC_GetNews" datasource="#request.datas ource#" username="#request.usernam e#" password="#request.passwor d#">
<cfprocresult name="qNews" maxrows="#maxrows#">
</cfstoredproc>
<cfreturn qNews>
</cffunction>
</component>
to display 2.
I'm trying to pass a maxrows variable with the value of 2, but doesn't work. Am I going about this correctly or is there a better way? I'm trying to utilize one stored procedure.
<cfscript>
objNews = createObject("component","
qNews = objNews.GetNews(maxrows = 2);
</cfscript>
<cfcomponent>
<!------------------------
GetNews: Returns the news articles
--------------------------
<cffunction name="GetNews">
<cfif IsDefined("maxrows")>
<cfset maxrows = maxrows>
<cfelse>
<cfset maxrows = "-1">
</cfif>
<cfstoredproc procedure="LC_GetNews" datasource="#request.datas
<cfprocresult name="qNews" maxrows="#maxrows#">
</cfstoredproc>
<cfreturn qNews>
</cffunction>
</component>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you RCorfman for a detailed explaination!
Thank you mrichmon for cleaning up the code!