Example Number 3.3

Example Name: SearchProducts.cfc

Language: CFML

Version: 1.0.0

Code:

<cfcomponent displayName="SearchProducts">
  <cffunction name="getSearchResult" access="remote" returnType="query">
    <cfargument name="search" type="string" default="%">
    <cfquery name="rsGetProducts" datasource="Northwind">
     SELECT ProductName, UnitPrice, QuantityPerUnit
     FROM Products 
     WHERE ProductName LIKE '%#search#%' 
    </cfquery>
    <cfreturn rsGetProducts>
  </cffunction>
</cfcomponent>

Download code text

Download chapter example files