QueryExecute

QueryExecute( sql [, params [, options [, name ] ] ] )

Returns: any

Argument Description
sql
string, required

SQL to execute

params
any, optional

Array or as a structure of parameter values.

When passing an array use ? as place holders and pass them in the order they are to be used.

When passing a struct use :keyName where keyName is the name of the key in the structure corresponding to the parameter.

The array or structure can be a structure with keys that match the names of the cfqueryparam names: maxlength, list, scale, separator, null, cfsqltype|sqltype|type and value

Alias: param

options
struct, optional

Struct containing query options, all cfquery tag attributes are supported except the name attribute.

Alias: option, queryOptions

name
string, optional

name of the query produced, visible in dumps or debugging output.

Alias: queryName

Examples

<cfscript>
    _test = queryNew(
        "_id, _need, _forWorld",
        "integer, varchar, varchar", 
        [[01,'plant', 'agri'],[02, 'save','water']]
    );
    queryResult = queryExecute(
        sql = 'SELECT * FROM _test WHERE _need = :need',
        params = {
            need: {
                value: "plant",
                type: "varchar"
            }
        },
        options = {
            dbtype = 'query'
        }
    );
    dump(queryResult);
</cfscript>

See also