[Mydatabasepilot-cvs] MyDatabasePilot/Query SELECT.cfm,NONE,1.1
Status: Alpha
Brought to you by:
nanoface
From: <nan...@us...> - 2003-04-18 04:01:44
|
Update of /cvsroot/mydatabasepilot/MyDatabasePilot/Query In directory sc8-pr-cvs1:/tmp/cvs-serv17080 Added Files: SELECT.cfm Log Message: Functionality Added: [ 720893 ] Create totally dynamic Select Statement --- NEW FILE: SELECT.cfm --- <!---******************************************************************************************* * Copyright: MyDatabase Pilot is distributed under the terms of the GNU GPL license * * Template: Query/SELECT.cfm * * Purpose: - Creates a Record Set with a Dynamic Select Statement * * - Everything from the Query Name, to the selected fields, to the selected * * tables, limit records are dynamic, therefore all these parameter must be * * provided, when calling this template * * Requiremets: - Connection Variables must already be set * * - queryName must have been passed to current template as either of Scope * * URL or FORM * * - Selected fields can either be passed or else it is assumed that all * * fields "*" are required * * - Either Table names or the select list string must have been Passed to * * overite default "*" * ********************************************************************************************---> <!----------------------> <!--- Error Checking ---> <!----------------------> <!--- Check that either a table(s) name exists or that a select string is provided to overwrite default "*" ---> <!-------------------------------------------------> <!--- Generate Select Statement Clause Strings ---> <!-------------------------------------------------> <!---||| Select Options List String |||---> <cfparam name="selectOptionsString" default=""> <!---||| Select List Clause String |||---> <!--- This is the only clause that is required by MySQL ---> <!--- We set it to the default of "*", which means all columns from the tables named in the FROM clause ---> <cfparam name="selectListString" default="*"> <!---||| Into Outfile Clause String |||---> <cfparam name="intoOutfileString" default=""> <!---||| From Clause String |||---> <!--- Set Default to Empty String ---> <cfparam name="fromString" default=""> <!--- Check to see if table value exists, scope is not specified because it could be a Local, URL, or FORM variable ---> <cfif IsDefined("table")> <!--- Add Table to fromString ---> <cfset fromString = "#table#"> </cfif> <!---||| Where Clause String |||---> <cfparam name="whereString" default=""> <!---||| Group By Clause String |||---> <cfparam name="groupByString" default=""> <!---||| Having Clause String |||---> <cfparam name="havingString" default=""> <!---||| Order By Clause String |||---> <cfparam name="orderByString" default=""> <!---||| Limit Clause String |||---> <cfparam name="limitString" default=""> <!---||| Procedure Clause String |||---> <cfparam name="procedureString" default=""> <!--------------------------------> <!--- Execute Select Statement ---> <!--------------------------------> <!--- Initiate a Read Only lock to ensure the integrity of session variables ---> <cflock timeout=20 throwontimeout="no" type="readonly" scope="session"> <!--- Creates a Record Set with a Dynamic Select Statement ---> <!--- Query Name is Dynamic and must be provided to this generic template ---> <cfquery name="#queryName#" datasource="#session.dataSource#" username="#session.userName#" password="#session.password#"> <!--- Select Statement ---> SELECT <!--- List Select Options If Any ---> <cfif selectOptionsString IS NOT ""> #selectOptionsString# </cfif> <!--- Select List Clause (Required) ---> #selectListString# <!--- Add Into Outfile Clause If Any ---> <cfif intoOutfileString IS NOT ""> INTO OUTFILE #intoOutfileString# </cfif> <!--- Add From Clause If Any ---> <cfif fromString IS NOT ""> FROM #fromString# </cfif> <!--- Add Where Clause If Any ---> <cfif whereString IS NOT ""> WHERE #whereString# </cfif> <!--- Add Group By If Any ---> <cfif groupByString IS NOT ""> GROUP BY #groupByString# </cfif> <!--- Add Having Clause If Any ---> <cfif havingString IS NOT ""> HAVING #havingString# </cfif> <!--- Add Order By Clause If Any ---> <cfif orderByString IS NOT ""> ORDER BY #orderByString# </cfif> <!--- Add Limit Clause If Any ---> <cfif limitString IS NOT ""> LIMIT #limitString# </cfif> <!--- Add Procedure Clause If Any ---> <cfif procedureString IS NOT ""> PROCEDURE #procedureString# </cfif> <!--- End SQL Statement ---> ; </cfquery> </cflock> |