Struct SafePrepared
Encapsulation of a prepared statement.
struct SafePrepared
;
Create this via the function prepare
. Set your arguments (if any) via
the functions provided, and then run the statement by passing it to
exec
/query
/etc in place of the sql string parameter.
Commands that are expected to return a result set - queries - have distinctive
methods that are enforced. That is it will be an error to call such a method
with an SQL command that does not produce a result set. So for commands like
SELECT, use the query
functions. For other commands, like
INSERT/UPDATE/CREATE/etc, use exec
.
Constructors
Name | Description |
---|---|
this
(sql, headers, numParams)
|
Constructor. You probably want prepare instead of this.
|
Properties
Name | Type | Description |
---|---|---|
columnSpecials [get, set]
|
ColumnSpecialization[] | Get/set the column specializations. |
lastInsertID [get]
|
ulong | After a command that inserted a row into a table with an auto-increment ID column, this method allows you to retrieve the last insert ID generated from this prepared statement. |
numArgs [get]
|
ushort | Gets the number of arguments this prepared statement expects to be passed in. |
preparedFieldDescriptions [get]
|
FieldDescription[] | Gets the prepared header's field descriptions. |
preparedParamDescriptions [get]
|
ParamDescription[] | Gets the prepared header's param descriptions. |
Methods
Name | Description |
---|---|
getArg
(index)
|
Prepared statement parameter getter. |
setArg
(index, val, psn)
|
Prepared statement parameter setter. |
setArgs
(args)
|
Bind a tuple of D variables to the parameters of a prepared statement. |
setArgs
(args, psnList)
|
Bind a MySQLVal[] as the parameters of a prepared statement. |
setNullArg
(index)
|
Sets a prepared statement parameter to NULL. |
sql
()
|
Gets the SQL command for this prepared statement. |