First things first, you will need a database and Coldfusion 9 for this to work. Once you have these two things you’ll need to create your Application.cfc file.
Remember in Coldfusion 8 using the THIS scope at the top of the component outside of any functions to set things like the name of the application, the session management, and the application timeout. Well, now you need to add to that list a few new settings in the THIS scope. You’ll need to add THIS.ormenabled = true and THIS.datasource = “yourdatasource”.
So our very simple Application.cfc file will look like the following.
Application.cfc
<cfcomponent displayname="Application File" hint="Application File" output="false"> <!--- SET UP ORM ---> <cfset THIS.name = "applicationTest"> <cfset THIS.datasource = "datasource"> <cfset THIS.ormenabled = true> </cfcomponent>
Keep in mind that setting the datasource in the THIS scope is the same thing you did in Coldfusion 8 when you would set the datasource in the tag. Point being that this datasource is pretty useless without setting up the datasource in the Coldfusion Administrator first. Take a look at Setting up a datasource to learn more about this. The really freakin awesome thing about this though is that setting the datasource here sets it globally across your application, which means for every call to the database you do not need to specify the datasource. This is a big deal in my book.
So ORM should be all set in your application.
DISCLAIMER** This is a record of what I’m learning in ORM in Coldfusion 9. While what I post should work, I lay no claim to best practices. My hope here is that other ORM beginners like myself may benefit from this information on the assumption that their path to learning ORM might be similar to my own. To learn more about ORM by those who know more than myself check out (of course) the adobe docs and a couple very nice presentations on cfmeetup.com by Raymond Camden and Bob Silverberg.
[...] pukkared Web Design & Development Setting up ORM in Coldfusion 9 [...]