Don't understand cffunction and cfcomponent
I am trying to alter Forta's ajax related select tutorial to fit my needs. I am having trouble understanding the details of this .cfc though.
<cfcomponent output="false">
<!--- Get array of media types --->
<cffunction name="get_states" access="remote" returnType="array">
<cfset data="">
<cfset result=ArrayNew(2)>
<cfset i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,states
FROM state
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[1]=data.id>
<cfset result[2]=data.state>
</cfloop>
<cfreturn result>
</cffunction>
<!--- Get art by media type --->
<cffunction name="get_waters" access="remote" returnType="array">
<cfargument name="location" type="string" required="true" default="">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,name
FROM waters
WHERE bow_state = '#arguments.location#'
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[1]=data.id>
<cfset result[2]=data.name>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
</cfcomponent>
When I put '#arguments.id#' into the second query, I get results. However, I'd like to query by the name instead, so I am trying location. I don't fully understand so I am hacking around with this a bit but I'd like to 1 - get results by name instead of id and 2 - understand the arguments variable so I really know what is going on.
Thanks!
