Inserts, Updates, and Deletes
Last updated
Was this helpful?
Last updated
Was this helpful?
The following methods all have the same return value:
Name
Type
Required
Default
Description
values
struct | array<struct>
true
A struct or array of structs to insert in to the table.
options
struct
false
{}
Any additional queryExecute
options.
toSQL
boolean
false
false
If true
, returns the raw SQL string instead of running the query. Useful for debugging.
This call must come after setting the query's table using or .
You can insert a single record by passing a struct:
Raw values can be supplied to an insert statement.
Multiple rows can be inserted in a batch by passing an array of structs to insert
.
Name
Type
Required
Default
Description
columns
string | array
true
A single column, a list or columns, or an array of columns to return from the inserted query.
returning
is only supported in PostgresGrammar
and SqlServerGrammar
. Using this method on unsupported grammars will result in an UnsupportedOperation
exception. Be aware that using this method constrains your grammar choices.
Specifies columns to be returned from the insert query.
Name
Type
Required
Default
Description
values
struct
false
{}
options
struct
false
{}
Any additional queryExecute
options.
toSQL
boolean
false
false
If true
, returns the raw SQL string instead of running the query. Useful for debugging.
Updates a table with a struct of column and value pairs.
You can update a column based on another column using a raw expression.
Null values can be inserted by using queryparam syntax:
if you are using Lucee with full null support the following (easier) syntax is also allowed:
Name
Type
Required
Default
Description
values
struct
true
A struct of column and value pairs to add to the update clause.
Name
Type
Required
Default
Description
values
struct
true
A struct of column and value pairs to either update or insert.
options
boolean
false
{}
Any additional queryExecute
options.
toSql
boolean
false
false
If true
, returns the raw SQL string instead of running the query. Useful for debugging.
Performs an update statement if the configured query returns true
for exists
. Otherwise, performs an insert statement.
If an update statement is performed qb applies a limit( 1 )
to the update statement.
If the configured query returns 0 records, then an insert statement is performed.
Name
Type
Required
Default
Description
id
any
false
idColumn
string
false
"id"
The name of the id column for the delete shorthand.
options
boolean
false
{}
Any additional queryExecute
options.
toSql
boolean
false
false
If true
, returns the raw SQL string instead of running the query. Useful for debugging.
Deletes all records that the query returns.
The id
argument is a convenience to delete a single record by id.
You can specify any options such as the SQL type by passing a struct with the parameters you would pass to .
A struct of column and value pairs to update. These column and value pairs are appended to any already set with the method.
This call must come after setting the query's table using or .
You can specify any options such as the SQL type by passing a struct with the parameters you would pass to .
Any constraining of the update query should be done using the appropriate statement before calling update
.
Adds values to a later , similar to .
A convenience argument for `where( "id", "=", arguments.id ). The query can be constrained by normal methods as well.