|
Jump Start To ColdFusion MX
By: Clint Tredway
Published: 24th Sep 2000
Introduction
This
article is going to be a guide to
Macromedia's ColdFusion MX (CF).
For those who have never used it
before, I am going to explain CF's
syntax and how it works in general.
I am going to present ColdFusion
from the basics so that you can get
an understanding on how it works
and how to start using it.
What Is ColdFusion?
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.
more
|
|