SafePrepared.setArgs - multiple declarations

Function SafePrepared.setArgs

Bind a tuple of D variables to the parameters of a prepared statement.

void setArgs(T...) (
  T args
)
if (T.length == 0 || !is(T[0] == Variant[]) && !is(T[0] == MySQLVal[]));

You can use this method to bind a set of variables if you don't need any specialization, that is chunked transfer is not neccessary.

The tuple must match the required number of parameters, and it is the programmer's responsibility to ensure that they are of appropriate types.

Type Mappings

See the MySQL/D Type Mappings tables

Function SafePrepared.setArgs

Bind a MySQLVal[] as the parameters of a prepared statement.

void setArgs (
  taggedalgebraic.taggedalgebraic.TaggedAlgebraic!(mysql.types._MYTYPE)[] args,
  ParameterSpecializationImpl!(true)[] psnList = null
) @safe;

You can use this method to bind a set of variables in MySQLVal form to the parameters of a prepared statement.

Parameter specializations (ie, for chunked transfer) can be added if required. If you wish to use chunked transfer (via psn), note that you must supply a dummy value for val that's typed ubyte[]. For example: cast(ubyte[])[].

This method could be used to add records from a data entry form along the lines of

auto stmt = conn.prepare("INSERT INTO `table42` VALUES(?, ?, ?)");
DataRecord dr;    // Some data input facility
ulong ra;
do
{
    dr.get();
    stmt.setArgs(dr("Name"), dr("City"), dr("Whatever"));
    ulong rowsAffected = conn.exec(stmt);
} while(!dr.done);

Type Mappings

See the MySQL/D Type Mappings tables

Parameters

NameDescription
args External list of MySQLVal to be used as parameters
psnList Any required specializations