Link to home
Start Free TrialLog in
Avatar of JRockFL
JRockFLFlag for United States of America

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.datasource#" username="#request.username#" password="#request.password#">
            <cfprocresult name="qNews" maxrows="#maxrows#">
      </cfstoredproc>      
      <cfreturn qNews>
</cffunction>
</component>
ASKER CERTIFIED SOLUTION
Avatar of mkishline
mkishline

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JRockFL

ASKER

Thank you mkishline!
Thank you RCorfman for a detailed explaination!
Thank you mrichmon for cleaning up the code!