Thursday, May 6, 2010

Coldfusion 9 ORM – Configuring Existing Database

Working with Coldfusion 9 and was very exited to begin using it, first experiment to configure existing database




Step 1 – Enable ORM and Define your database



Application.cfc



Component {

this.name = “dashboards”;

this.ormenabled = “true”;

this.datasource = “mycy”;

}

Step 2. Add your existing table properties, here I am considering table named “reportsdata”

reportsdata.cfc

/**

* @persistent

*/

Component

{

property name=”reportdataid” fieldtype=”id” generator=”increment”;

property reportdataname;

property reportdatavalue;

property adddate;

property addby;

property moddate;

property modby;

}

That’s all, now we can test it out

test.cfm

<cfscript>

reportData = EntityLoadByPK(“reportsdata”,40);

writedump(reportData);

</cfscript>

No comments: