Query Parameters and Bindings
Was this helpful?
Was this helpful?
When passing a parameter to qb, it will infer the sql type to be used. If you pass a number, NUMERIC
will be used. If it is a date, TIMESTAMP
, and so forth. If you need more control, you can pass a struct with the parameters you would pass to .
You can pass include any parameters you would use with including null
, list
, etc. This applies anywhere parameters are used including where
, update
, and insert
methods.
This can be used when inserting or updating records as well.
qb will use a different SQL type for integers and decimals. You can customize the SQL types by setting the integerSqlType
and decimalSqlType
settings.
Additionally, qb automatically calculates a scale based on the value provided if the value is a floating point number.
If you need to inspect the bindings for the current query you can retrieve them in order using the getBindings
method.
Use these methods only for debugging. Modifying the bindings directly will likely cause issues when executing your query. Adding or removing bindings should be done using the public API.
Name
Type
Required
Default
Description
No arguments
This method returns the current bindings in order to be used for the query.
You can also retrieve the bindings associated to their corresponding types.
Name
Type
Required
Default
Description
No arguments
This method returns the current bindings to be used for the query associated to their corresponding types.
Adds a single binding or an array of bindings to a query for a given type.
newBindings
Struct
| Array<Struct>
true
A single binding or an array of bindings to add for a given type.
type
String
false
"where"
The type of binding to add.
Adds all of the bindings from another builder instance.
qb
QueryBuilder
true
Another builder instance to copy all of the bindings from.
Bindings are the values that will be sent as parameters to a prepared SQL statement. This protects you from In CFML, this uses to parameterize the values.
You can view the current SQL for the query with bindings inline for debugging purposes using the method.