Blog

Blog posts made on 20-Jun-09
20Jun
2009
Look, No Datasource

Look at this code snippet. Notice anything odd about it?

view plain print about
1<cfquery name="Art">
2SELECT *
3FROM art
4ORDER BY ArtName
5</cfquery>

Yep, the <CFQUERY> tag in the above snippet is missing the DATASOURCE attribute. And yet, this code works. Why? Take a look at this Application.cfc file:

view plain print about
1<cfcomponent>
2    <cfset this.datasource="cfartgallery">
3</cfcomponent>

In ColdFusion Centaur you can now specify an application wide default datasource by setting this.datasource in Application.cfc. The specified datasource becomes the default for all <CFQUERY>, <CFSTOREDPROC>, and other tags that expect a datasource to be specified. Of course, datasource can still be specified manually if needed, and a specified datasource will override the application default one.

This is one of those duh! enhancements that just makes sense. And, as I'll explain in an upcoming post, it also has another important purpose.

Read More ›