ColdFusion & Verity - Getting Results Found When Paging
By Raymond Camden
Expert Author
Article Date: 2007-10-12
I was doing a code review this morning when I found this little gem:
<CFSEARCH NAME="pariscontactsTotal" COLLECTION="#collection#"
TYPE="#searchType#"
CRITERIA="#search#">
<CFSEARCH NAME="pariscontacts"
COLLECTION="#collection#"
TYPE="#searchType#"
CRITERIA="#search#"
STARTROW="#startrow#"
MAXROWS="#itemsPerPage#">
So why the duplicate searches? They wanted to return a page of data, but also tell the user how many total matches were returned.
This is far easier in ColdFusion 7 and higher.
If you add the "status" attribute to your CFSEARCH tag, you can a structure back that contains keys for: Found (how many total found, even if you paginate the results), Searched (total number of records in the collection), and Time (time it took to search).
They could get rid of that first cfsearch and just do this:
<CFSEARCH NAME="pariscontacts"
COLLECTION="#collection#"
TYPE="#searchType#"
CRITERIA="#search#"
STARTROW="#startrow#"
MAXROWS="#itemsPerPage#"
status="result">
I'd name the client - but I'd like to get paid. ;) I will point something they did that was very good (and something I forget to do from time to time).
Before searching, they run the search through verityClean first. A friend of mine had a site that didn't do this - but as he owes me beer, I won't name him either. ;)
Comments
About the Author:
Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com
Raymond Camden is Vice President of Technology for roundpeg, Inc. A long
time ColdFusion user, Raymond has worked on numerous ColdFusion books
and is the creator of many of the most popular ColdFusion community web
sites. He is an Adobe Community Expert, user group manager, and the
proud father of three little bundles of joy.
|
|