Skip to content

Instantly share code, notes, and snippets.

@christophervigliotti
Last active March 1, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophervigliotti/db66462e9c9d278c5bd9686b6aa18e00 to your computer and use it in GitHub Desktop.
Save christophervigliotti/db66462e9c9d278c5bd9686b6aa18e00 to your computer and use it in GitHub Desktop.
A ColdFusion Component using nothing but cfscript
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