ColdFusion 9 Component Script
I know there are many users out there who love cfscript and many who really don't care for the syntax. I am really on the fence, I like the syntax but do not use it much because of the lack of support for certain tags and on the presentation layer it just does not mix well for me. One of the main reasons that Adobe is yet to support full scripting is the cfqueryparam tag. I am hoping that in the next version of ColdFusion they find a way to resolve this.
I have been doing some ActionScript 3 development lately and I really love the language. So with that I have a small proposal for CF9 that I am sure some people will be with and some are going to hate it. Day to day I write many Components so I think it would be really cool to write components using scripting. With that said here is an example of what I would like to be able to do.
variables.dsn = "";
public function init(String:dsn):User{
variables.dsn = arguments.dsn;
return this;
}
public function getUsers():query {
var q = new cfquery();
q.name = "q";
q.datasource = variables.dsn;
q.sql = "SELECT * FROM Users"
q.execute();
return q;
}
public function getUser(Numeric:id):Struct {
var q = new cfquery();
q.name = "q";
q.datasource = variables.dsn;
q.sql = "SELECT * FROM Users WHERE id = " + arguments.id;
q.execute();
return queryRowToStruct(q);
}
</cfcomponent>
