Coldfusion ORM in CFScript version

In these days, I feel like myself to write all of CF coding in CFScript version. Because most of CF Developers said CFScript coding can enhance your projects than normal CFML coding. That's why I want to develop my simple ORM projects with CFScript as testing purpose.

view plain print about
1<!--- Application.cfm --->
2
3component output="false" {
4THIS.name = "CFScriptORM";
5THIS.applicationTimeout = createTimeSpan(0, 1, 0, 0);
6THIS.clientManagement = false;
7THIS.datasource = "cfartgallery";
8
9THIS.loginStorage = "cookie";
10THIS.sessionManagement = true;
11THIS.sessionTimeout = createTimeSpan(0, 0, 30, 0);
12
13THIS.ormenabled = true;
14THIS.ormsettings = {};
15
16public void function onError(required any Exception, required string EventName) {
17
18 if (ListFindNoCase("onSessionEnd, onApplicationEnd", Arguments.EventName) IS 0)
19 {
20 WriteOutput("<h2>An unexpected error occurred.</h2>");
21 WriteOutput("<p>Please provide the following information to technical support:</p>");
22 WriteOutput("<p>Error Event: #Arguments.EventName#</p>");
23 WriteOutput("<p>Error details: #Arguments.Exception.message#<br>");
24 }
25return;
26}
27}

[More]

Need to restart CF server when I create new CFC for ORM

Today, free feel to test simple ORM project for my future project. As some developers said, ORM can provide us clean Code, high performance and can develop database application faster. Likewise, developers don't need to stick into database manipulation just like before. According Adobe Coldfusion documentation, they describe as follow:

ColdFusion ORM automates most of these tasks, which:

  • Makes application code cleaner and more manageable
  • Enhances your productivity and lets you develop database applications faster
  • Creates applications that can run faster because of built-in ORM optimizations
  • Minimizes the amount of code you write

That's why I've created simple ORM application.

application.cfc

view plain print about
1<cfset this.name = "myORMtest">
2<cfset this.ormenabled = "true">
3<cfset this.datasource = "myORMtestDSN">

NH_NATIONALITY.cfc

view plain print about
1<cfcomponent persistent="true">
2 <cfproperty name="id" column = "NATIONALITY_ID" generator="increment">
3 <cfproperty name="NATIONALITY_CODE">
4 <cfproperty name="NAME">
5</cfcomponent>

index.cfm

view plain print about
1<cfform action="index.cfm" method="post">
2    <cfinput type="Text" name="txtCode" required="Yes">
3    <input type="Submit" name="btnSubmit">
4</cfform>
5
6<cfif StructKeyExists(form, "btnSubmit")>
7    <cfset getQueryNA = EntityLoad("NH_NATIONALITY", {NATIONALITY_CODE = form.txtCode})>
8    <cfdump var="#getQueryNA#">
9</cfif>

[More]

Top of Page