ColdFusion 4.0 Primer

Introduction

The time will eventually come when you need to work with a database for a website. Using a database greatly enhances your ability to add and remove content, and all in all it requires less work to set up.

Take this website for example. With its many articles without the use of a database a separate web page would have to be made for each and every article. Sure you could automate things with SSI but you would still have to make a separate page for each article.

With a database this is different, you can simply make a single page to view all of your articles. You simply pass a variable in the link such as ID=2 and that tells the database to serve article number 2. How to do this will be explained in this article.

There are 3 main programming languages used to access databases. PHP, which is normally found on unix/linux platforms, ASP, which is a creation of Microsoft and is found mostly on NT platforms, and ColdFusion(CF), which is found mostly on NT platforms as well. There is also JSP but it is as of yet not as popular as the other three, and Perl which is an older technology and not really in the same league.

This article will show you how to use ColdFusion to access a database from a website and use it to display information.

About ColdFusion

ColdFusion was created as a commercial product by the Allaire Corporation (now owned by Macromedia). As a commercial product it has some features different from other Server Side Scripting Languages. The first major difference is that ColdFusion scripts do not have to display their source code like every other scripting language (PHP can do this with a software add on from Zend), it is possible to run encrypted versions of the scripts. This allows for individuals to sell their own scripts without fear of piracy, however it has the side effect of stemming the flow of free open source CF scripts for use by the learning webmaster. The second major difference is that ColdFusion costs money. A server side scripting language works with an interpreter. Depending on the extension of the filename to be served, .php .asp or .cfm, the server will first send the file to an interpreter which is what dynamically generates your page. So to use these languages you need to install them on your server. PHP is free, ASP is free (after paying for Windows Server), but CF costs money, and that may be the reason why it is growing only slowly. However many NT hosting packages do already include ColdFusion so for the person who does not own their own server this pricing difference will not have much affect. Still though, because of the costs, you usually find ColdFusion powering major corporate applications rather than small independent websites.

As to the language itself, I have worked with both ASP and PHP before and it is my opinion that ColdFusion is the easiest to learn and use if you are a beginner to programming. This is because ColdFusion is a fourth generation scripting language, meaning it is so far removed from machine code that it's syntax is very simple.