Created
February 15, 2022 01:51
-
-
Save trycf/9fa88c22da3d85270d6e5d2758adb66d to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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