My cheesy non-database ColdFusion Code for Model-Glue.com

I’ve already had a few requests to update the list of sites over on the Model-Glue site. I thought I’d share the Super Cool code I used to build the page. I didn’t want to use the database, so I whipped up the following precious bit of code: <!--- Ray's hack to avoid a DB. Yes, this is the suck. ---> <cfset sites = queryNew("title,url,description")> <cfsavecontent variable="data"> iRovr@http://www.irovr.com@iRovr is a unique social experience developed exclusively for the iPhone. Members can blog, share photos, bookmark urls and link to YouTube videos by sending emails to POP aliases created specifically for their account. Stavanger2008@http://www.stavanger2008.com@In 2008 Stavanger (norway) will be the European Capital of Culture. This is his official web site. BPO Pros@http://bpoprosonline.com@MI based Realtor </cfsavecontent> <cfset data = trim(data)> <cfloop index="line" list="#data#" delimiters="#chr(13)##chr(10)#"> <cfset site = listFirst(line,"@")> <cfset theurl = listGetAt(line,2,"@")> <cfset desc = listLast(line,"@")> <cfset queryAddRow(sites)> <cfset querySetCell(sites, "title", site)> <cfset querySetCell(sites, "url", theurl)> <cfset querySetCell(sites, "description", desc)> </cfloop>

I deleted some of the text data - but as you can see - I build a fake query based on a string delimited by @ signs. The first part of each line is the site title, then the URL, and then the description. Later on in the page I just output over the query like it was any other ‘real’ query. If I ever make a real database application out of this page, I just need to point to a CFC to get the query.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments