In ColdFusion (2018 release), script functions implemented as CFCs are deprecated in ColdFusion.
Used to execute a query passing SQL statements to a data source using CFScript.
Mode |
Syntax |
---|---|
Creating the service |
new query() or createObject("component", "query") |
Initializing the attributes |
Any one of the following:
|
Executing the service action |
queryService.execute(attribute-value_pair) |
name |
blockfactor |
cachedafter |
cachedwithin |
dataSource |
dbtype |
debug |
maxRows |
password |
result |
timeout |
username |
sql |
|
|
|
All attributes supported by the tag cfquery can be used as attribute-value pairs. For example,
<cfquery Name="myName"> </cfquery> |
can be used as
queryService.setName("myName"); |
ColdFusion 9: Added this function.
addParam
Description |
Used in CFScript to add cfqueryparam tags to: |
For DBMSs that support bind variables, to enable ColdFusion to use bind variables in the SQL statement
Syntax |
serviceName.addParam(attribute-value pair) |
Returns |
Nothing |
Arguments |
All attributes supported by cfqueryparam tag can be used as attribute-value pairs. |
execute
Description |
Used to execute SQL statements. |
Returns |
A component with the following properties set: |
Prefix: Equivalent to the result attribute for the cfquerytag.
Syntax |
queryService.execute(attribute-value pair) |
Arguments |
All attributes supported by the cfquery tag. |
setAttributes
Description |
Sets attributes for the query function. |
Returns |
Nothing |
Syntax |
queryService.setAttributes (attribute-value pair) |
Arguments |
All attributes supported by the cfquery tag. |
getAttributes
Description |
Gets attributes that were set for the query function. |
Returns |
Returns a struct with all or some of the attribute values. |
Syntax |
queryService.get_Attributes_ (attributelist) |
Arguments |
A comma-separated list of attributes. If no list is specified, all defined attributes are returned. |
clearAttributes
Description |
Removes all attributes added for the query function. |
Returns |
Nothing |
Syntax |
queryService.clearAttributes(attribute_list) |
Arguments |
A comma-separated list of attributes. |
clearParams
Description |
Removes queryparams that were added using the addParam method. |
Returns |
Nothing |
Syntax |
queryService.clearParams() |
Arguments |
None |
clear
Description |
Removes all attributes and queryparms that were added using the addParam method. |
Returns |
Nothing |
Syntax |
queryService.clear() |
Arguments |
None |
This function corresponds to the cfquery tag. For usage information, see Usage details for cfquery.
<cfscript> |
Sign in to your account