Making our data query flexible
We set the default value so the page doesn't fail if there is no value for the ID variable passed in. We added the singular getProduct
variable. It actually returns a recordset just like rsProducts
returns a recordset. The only difference is that this will return a single record after we modify the CFC. Currently the CFC doesn't handle the where
argument even though it is part of the method. We have to build in the functionality. This is what the method should look like now. Change the highlighted lines to make this method work correctly. As we are not adding the query type to the <cfoutput>
tag inside the if condition where there is only one record, it will not loop through the query. It will only return the first record in the recordset. In this instance there is only one record, so that would be the same. This information is just for future reference, so we will understand why only one row appears on our web page and why we have to declare the query...