Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/9fa88c22da3d85270d6e5d2758adb66d to your computer and use it in GitHub Desktop.
Save trycf/9fa88c22da3d85270d6e5d2758adb66d to your computer and use it in GitHub Desktop.
TryCF Gist
<cffunction name="orders" returntype="any">
<cfargument name="inparam" required="false" default="" type="any">
<cfargument name="search" required="false" default="">
<cfparam name="start" default="10" type="integer" />
<cfparam name="length" default="10" type="integer" />
<cfset var rsQuery = ''>
<cfsavecontent variable="MainQuery">
SELECT *
FROM
bills
WHERE
billtype = 'Bill'
</cfsavecontent>
<cfquery name="rsQuery" datasource="#Application.dsn#">
#preserveSingleQuotes(MainQuery)#
<cfif len(trim(search))>
AND
(
<cfloop list="#listColumns#" index="thisColumn">
<cfif thisColumn neq listFirst(listColumns)>
OR
</cfif>
#thisColumn# LIKE <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="%#trim(search)#%" />
</cfloop>
)
</cfif>
ORDER BY BillID desc
LIMIT #start# OFFSET #length#
</cfquery>
<cfdump var="#rsQuery#" abort>
<cfreturn rsQuery>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment