Last active
March 1, 2022 16:30
-
-
Save christophervigliotti/db66462e9c9d278c5bd9686b6aa18e00 to your computer and use it in GitHub Desktop.
A ColdFusion Component using nothing but cfscript
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
component { | |
// properties | |
variables.a_property = ''; | |
// init | |
public any function init( | |
String an_argument | |
){ | |
variables.a_property = arguments.an_argument; | |
return this; | |
} | |
// methods | |
public string function functionName( | |
String an_argument = 'default value' | |
){ | |
// declare vars | |
var a_variable = 0; | |
// logic | |
// return | |
return a_variable; | |
} | |
public string function functionWithQuery(){ | |
// declare vars | |
var query_results = ''; | |
var query_object = new Query( | |
name="query_name", | |
datasource="datasource_name", | |
sql = " | |
select | |
col1, | |
col2 | |
from | |
tablename | |
where | |
id=:id | |
and thingie=:thingie | |
" | |
); | |
// logic | |
query_object.addParam(name="id", value=arguments.wat, cfsqltype="cf_sql_integer"); | |
query_object.addParam(name="thingie", value=arguments.thingie, cfsqltype="cf_sql_varchar"); | |
query_results = query_object.execute().getResult(); | |
// return | |
return query_results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment