CFML Developers Evolution Scribble
Having done an import of my old Gmail account into a single Google Apps account, a few old emails came into my inbox, one of which was from my brother with a link to: PHP programmer's evolution scribble
So it made me think about this in the CFML World, so here it is:
Your First CFQuery
<cfquery name="GetParks" datasource="cfsnippets">
SELECT PARKNAME, REGION, STATE
FROM Parks
WHERE Parkname = "#url.parkname#"
</cfquery>
Your Second CFQuery
<cfset request.dsn = "cfsnippets"/>
<cfquery name="GetParks" datasource="#request.dsn#">
SELECT PARKNAME, REGION, STATE
FROM Parks
WHERE Parkname = "#url.parkname#"
</cfquery>
You then hear about SQL Injection
<cfset request.dsn = "cfsnippets"/>
<cfquery name="GetParks" datasource="#request.dsn#">
SELECT PARKNAME, REGION, STATE
FROM Parks
WHERE Parkname = <cfqueryparam value="#url.parkname#" cfsqltype="CF_SQL_VARCHAR">
</cfquery>
Then after changing code after uploading you come up with
<cfset request.live = "true"/>
<cfif request.live>
<cfset request.dsn = "cfsnippetslive" />
<cfelse>
<cfset request.dsn = "cfsnippetsdev" />
</cfif>
Then you go to a conference / Usergroup meeting / online web meeting
<cfscript>
if (cgi.REMOTE_HOST is "mylivedomain.com") {
request.dsn = "cfsnippetslive";
}
else {
request.dsn = "cfsnippetsdev";
}
</cfscript>
Then you chat with a DBA mate or get one in house
<cfstoredproc procedure="getParks" datasource="#request.dsn#">
<cfprocparam value="#url.parkname#" cfsqltype="CF_SQL_VARCHAR">
<cfprocresult name="GetParks">
</cfstoredproc>
Then...........
You go back to code your wrote back in stage one and think who the f**k wrote this shite, and because there were no comments you can blame everyone else execpt for yourself as you'd never write that now ;)
All I have to say is that we all develop, we can take this forward when people start to use Frameworks, Ant, Unit Testing, CI, Agile development etc.
We all have to admit it, our code has come along way from the day we started, and if you have only just started you'll laugh at this now saying I won't do that, and in 6 months time go back to old code and think, I've come along way since that day.
Did you like this post? Then
buy me a beer
CFML Developers Evolution Scribble
I dunno Kev. I think my first query was more like "Select * From...."