Jump Start To ColdFusion MX - What Is ColdFusion?
(Page 2 of 6 )
Let's begin with what ColdFusion is. ColdFusion is really two things. First off, ColdFusion is an application server that runs on multiple platforms. These platforms include Windows, Linux, Solaris, and HP Unix. Second, ColdFusion is a scripting language that allows for rapid application development.
ColdFusion has a very simple syntax that follows HTML syntax. Here's a simple example:
<cfset myvar = "Hello World"> This example sets a variable named myvar with the value of "Hello World". Because of this simple syntax, ColdFusion programmers can create web applications a lot quicker than they could be using many other scripting languages.
I am now going to go over some simple syntax of the ColdFusion language. First, let's discuss how to set a variable in ColdFusion. To set a variable to a specific value, the <cfset> tag is used. Here is an example of the syntax to set a variable called myvar to a string value of "ColdFusion Rocks!".
<cfset myvar = "ColdFusion Rocks!"> Now, I hear you saying, "Well that does me no good unless I can output the contents of the variable", so here's how you would output the variable:
<cfoutput>#myvar#</cfoutput> Ok, lets talk about the last code snippet. All ColdFusion variables are enclosed in pound (#) signs and to output those variables, they are enclosed in <cfoutput> tags.
Now, the <cfoutput> tag is your friend. Not only does it output variables, but it can also loop through query results. Since I have just brought up the subject of queries, let talk about how to query a database. Following the naming convention of other CF tags, the <cfquery> tag is used to query a database. Here’s an example of a database query in ColdFusion:
<cfquery name="myQuery" datasource="MyDSN">
Select col1, col2 from anytable
</cfquery> Let's breakdown this example so that you will know what's going on. The 'name' attribute tells ColdFusion how to reference the query result that this query is generating. The 'datasource' attribute tells ColdFusion what database or DSN to connect to in order to execute the query inside of the <cfquery> tag. Almost all SQL statement can be executed inside a <cfquery> tag. Generally speaking, 99% of all SQL queries will run inside this tag.
Next: Showing The Results Of A Query >>
More ColdFusion Articles
More By Clint Tredway