root/coldbox/trunk/install/illidium_templates/coldbox/gateway/getByAttributesQuery.cfm @ 809

Revision 809, 1.4 kB (checked in by lmajano, 6 years ago)

Illidium Scaffolding Templates

  • Property svn:executable set to *
Line 
1        <%cffunction name="getByAttributesQuery" access="public" output="false" returntype="query"%>
2                <cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i"><%cfargument name="#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#" type="#root.bean.dbtable.xmlChildren[i].xmlAttributes.type#" required="false" /%>
3                </cfloop><%cfargument name="orderby" type="string" required="false" /%>
4               
5                <%cfset var qList = "" /%>             
6                <%cfquery name="qList" datasource="%variables.dsn%"%>
7                        SELECT  <cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i">#chr(13)#                             #root.bean.dbtable.xmlChildren[i].xmlAttributes.name#<cfif i neq arrayLen(root.bean.dbtable.xmlChildren)>,</cfif></cfloop>
8                        FROM    #root.bean.dbtable.xmlAttributes.name#
9                        WHERE           0=0<cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i">#chr(13)#          <%cfif structKeyExists(arguments,"#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#") and len(arguments.#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#)%>
10                        AND     #root.bean.dbtable.xmlChildren[i].xmlAttributes.name# = <%cfqueryparam value="%arguments.#root.bean.dbtable.xmlChildren[i].xmlAttributes.name#%" CFSQLType="#root.bean.dbtable.xmlChildren[i].xmlAttributes.cfSqlType#" /%>
11                <%/cfif%></cfloop>
12                <%cfif structKeyExists(arguments, "orderby") and len(arguments.orderBy)%>
13                        ORDER BY %arguments.orderby%
14                <%/cfif%>
15                <%/cfquery%>
16               
17                <%cfreturn qList /%>
18        <%/cffunction%>
Note: See TracBrowser for help on using the browser.