Database Reference
In-Depth Information
Figure 14.13
A verified data source.
The template file is a collection of CFML code and HTML tags. The CFML tags control
sending of data to the data source and control the output of the HTML code.
The following template, when executed through a ColdFusion server, will send a query
to our data source and output some of the results:
<HTML>
<TITLE>Testing MySQL ODBC Connection</TITLE>
<BODY>
<CFQUERY name=”getusers” datasource=”MyTestDataSource”>
SELECT *
FROM user
</CFQUERY>
<CFOUTPUT query=”getusers”>
#USER#@#HOST#<BR>
</CFOUTPUT>
</BODY>
</HTML>
The result of running this template is shown in Figure 14.14.
We will examine the contents of this template to show what is happening. The template
begins with standard HTML which is passed straight back to the webserver:
<HTML>
<TITLE>Testing MySQL ODBC Connection</TITLE>
<BODY>
This defines the file as HTML and sets the title of the page. Then comes the first CFML
tag:
<CFQUERY name=”getusers” datasource=”MyTestDataSource”>
SELECT *
FROM user
</CFQUERY>
Search WWH ::




Custom Search