Application-wide datasource in Railo
Another one of those features that I knew was is in CF 9 but didn't know was in Railo and thats Application wide datasource name.
What this means is that in your Application.cfc (NOT .cfm!) you can set a per-application datasoure which lets you ommit the "datasource" attribute in your <cfquery> tags.
Your Application.cfc
1<cfcomponent displayname="Application.cfc">
2<cfscript>
3 // Set the application name
4 this.name = "myApp" & hash(getCurrentTemplatePath())
5
6 // Set the datasource
7 this.datasource = "myDSN";
8
9</cfscript>
10</cfcomponent>
2<cfscript>
3 // Set the application name
4 this.name = "myApp" & hash(getCurrentTemplatePath())
5
6 // Set the datasource
7 this.datasource = "myDSN";
8
9</cfscript>
10</cfcomponent>
Your test.cfm page
1<cfquery name="qry">
2 SELECT * FROM yourTable
3 </cfquery>
4 <cfdump var="#qry#" label="Query Dump">
2 SELECT * FROM yourTable
3 </cfquery>
4 <cfdump var="#qry#" label="Query Dump">
| Tweet |
| If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck. |