Should I Use a Dynamic "Get" Function?
So let's say I have a table called "Book", and it has the columns "ID, Name, Author, ISBN"
I'm wondering what the Pros and Cons would be to creating a function to get books by any attribute using one function:
<cffunction name="GetBook">
<cfargument name="Identifier" type="string">
<cfargument name="Value" type="string">
<cfquery name="Books">
SELECT ID, Name, Author, ISBN FROM Book
WHERE #Arguments.Identifier# = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Arguments.Value#">
</cfquery>
<cfreturn Books>
</cffunction>
So that I could call the following functions:
GetBook('ID', 7);
GetBook('Name', 'To Kill a Mockingbird');
GetBook('Author', 'John Gisham');
GetBook('ISBN', '0321515471');
Thoughts?