ColdFusion has a special data type called query. Recordsets returned from a database are of this data type and are called "queries".
The <cfquery> tag is used to send queries to a database and to store the results returned in a query variable.
|name||Name of query.|
|datasource||Name of data source.|
|dbtype||Only possible value is "query". Used with query of queries.|
|username||Overrides username set up in ColdFusion Administrator.|
|password||Overrides password set up in ColdFusion Administrator.|
|maxrows||Maximum number of rows to return in record set.|
|blockfactor||Maximum rows to get at a time from server.|
|timeout||Number of seconds that each action of a query is permitted to execute before returning an error.|
|cachedafter||Date value specifying when to drop query from cache.|
|cachedwithin||Timespan for which to hold query in cache.|
|debug||Turns debugging display on or off.|
The query object created by this tag has the following properties.
|currentRow||Current record of the query being processed.|
|columnList||Comma-delimited list of column names.|
|recordCount||Number of records returned by query.|
|executionTime||Time it took to execute query.|
You can find out how long a query takes to process by reading the cfquery.executionTime variable.
This following example is very similar to the previous one, except that the valid username and password are not hardcoded in the script but instead are searched for in a database.
<cfif isDefined("FORM.submitted")> <cfquery name="logincheck" datasource="runners"> SELECT FirstName, LastName, Email FROM Users WHERE email='#FORM.email#' AND password='#FORM.password#' </cfquery> <cfif logincheck.RecordCount> <cflocation url="index.cfm" addtoken="no"> </cfif> </cfif> ---- C O D E O M I T T E D ----