ColdFusion 9.0 Resources |
Using the CF.query functionYou use the CF.query function in your server-side ActionScript to retrieve data from a ColdFusion data source. This function lets you perform queries against any ColdFusion data source. Note: The CF.query function maps
closely to the cfquery CFML tag, although it currently
supports a subset of the cfquery attributes.
Use the CF.query function to do the following:
For reference information about the CF.query function, see CF.query in the CFML Reference. About CF.query function syntaxYou can write the CF.query ActionScript function using either named arguments or positional arguments. The named argument style is more readable, but it requires more code. Although the positional argument style supports a subset of CF.query arguments, it allows a more compact coding style that is more appropriate for simple expressions of the CF.query function. Using CF.query named argument syntaxThe CF.query function accepts the following named arguments: // CF.query named argument syntax CF.query ({ datasource:"data source name", sql:"SQL stmts", username:"username", password:"password", maxrows:number, timeout:milliseconds }) Note: The named argument style requires curly brackets
{} to surround the function arguments.
Using CF.query positional argument syntaxPositional arguments support a subset of CF.query arguments, and you can create more efficient code. The following is the syntax for the positional argument style: // CF.query positional argument syntax CF.query(datasource, sql); CF.query(datasource, sql, maxrows); CF.query(datasource, sql, username, password); CF.query(datasource, sql, username, password, maxrows); Note: When using positional arguments, do not use
curly braces {}.
About the CF.query record setThe CF.query function returns a RecordSet object, which is an instance of the RecordSet class of objects. The RecordSet class provides a wide range of functions for handling record set data. You use methods in the RecordSet ActionScript class in your client-side ActionScript to change data returned in the CF.query record set. Currently, the following methods are available in the RecordSet class:
These functions are available for every RecordSet object returned by the CF.query function to the Flash client. You run these functions as follows: objectName.functionName(); For example, in the result function that you create to handle record set data returned by the CF.query function, you can reference the database column names returned in the record set using the getColumnNames RecordSet function: function selectData_Result ( result ) { //result holds the query data; employeesView is a Flash list box stringOutput.text = result.getColumnNames(); _root.employeesView.setDataProvider(result); } |