This ColdFusion tutorial is written for beginners and gives you an overview of the various components that make up the ColdFusion environment.
ColdFusion is an environment for creating web applications. To build applications, you first need to install the ColdFusion server. This ColdFusion tutorial will point you in the right direction.
You can install ColdFusion from disk or download it from the Macromedia website. ColdFusion (at least version MX 7) comes in the following editions: Developer, Standard, and Enterprise. The Developer edition is based on the Enterprise version but is limited to running on localhost and two other machines.
For more information see the installation tutorial.
The CF Administrator
The ColdFusion Administrator is a web interface that is automatically installed with ColdFusion. It provides developers with the ability to configure the CF implementation. Once you've installed ColdFusion, you can access the CF Administrator and configure it according to the needs of your website.
For more information see the CF Administrator tutorial.
You create ColdFusion applications using CFML. You could use a plain text editor but an easier method is to use an editor such as Dreamweaver. Dreamweaver recognises CFML, so it can make life easier. For example, it color codes your CFML tags to make your code easier to read, it provides a CFML reference, it provides a CFML menu, wizards etc.
You save your files with a .cfm extension. When the user requests a file with this extension, the web server passes it to ColdFusion server to interpret. CF will then process all the CFML then send the result back to the web server. The web server then sends the resulting HTML page to the user's browser.
If you need an editor, try downloading Dreamweaver
Like HTML, CFML tags have an opening tag and closing tag. Most CFML tags' purpose are quite self explanatory. Some common CFML tags include
Example of CFML:
<cfset firstName = "World"> Hello <cfoutput>#firstName#</cfoutput>! This CFML tutorial was designed for <cfif firstName eq "World"> you! <cfelse> the world to see. </cfif>
For more info see Macromedia's full list of CFML tags.
CFML provides a number of functions that you can use to perform logical and arithmetic operations and manipulate data. Common functions include
IsDefined() and many more.
To view all CFML functions see Macromedia's full list of functions
Connecting to a Database
Quite possibly, one of the most common things you will be doing as a ColdFusion developer is querying a database. To query a database, you need to do the following:
- Create a database
- Create a data source (via the ColdFusion Administrator) and point it to the database
- Query the database using CFML code. For example, something like this:
<cfquery>tag. For example, something like this:
<cfquery name="myQuery" datasource="myDataSource" username="myUsername" password="myPassword">
select * from customers
While it's true that you could provide your website users with search functionality using something like SQL, there is a more powerful alternative.
ColdFusion comes bundled with a third party search engine by Verity. This is a full text search engine that is well suited to searching unstructured documents. You can use Verity to search physical files (i.e. Word, PDF, Excel etc) or the results of a database query. When the user performs a search, Verity searches "collections" (that you previously configured and indexed). Verity provides a number of operators you can use to manipulate the search results and these are generally available in the form of a CF tag.
To learn more about Verity check out Macromedia's documentation.
This ColdFusion tutorial has provided an introduction to the main topic areas of ColdFusion. Specifically, we learned that you first need to install ColdFusion server. You then need to access the ColdFusion Administrator to configure your ColdFusion implementation. We saw a sample of the commonly used CFML tags and functions, learned how to connect to a database, and learned about the Verity search tool that comes bundled with ColdFusion.
Check out the more extensive ColdFusion tutorial.