< ColdFusion Programming

One of the most powerful original features of ColdFusion was the ability to easily connect to various databases.

Setting up Datasources

Almost any database can be used as long as it has a JDBC driver available. There are built in drivers for Access, MS SQL server and MySQL server. Additionally there is a built in ODBC bridge which should only be used if nothing else is available.

Choosing Data Sources within the ColdFusion Administrator will allow you to setup each datasource that you will need.

CFQuery

The way to connect to a database is by using CFQUERY.

Example:

<cfquery datasource="postal" name="getdata">
  SELECT *
  FROM zipcodes
</cfquery>

Attributes:

  • Datasource
  • Name
  • DbType

Return Variables:

  • ColumnList
  • RecordCount
  • CurrentRow
  • ExecutionTime

CFInsert

CFUpdate

Grouping Query Displays

Query of Queries

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.