mysql-native v1.2.0

API Reference Home: [This Version] [Latest Version] [Other Versions]


PreparedImpl.setArgs - multiple declarations

Function PreparedImpl.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[]));

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 PreparedImpl.setArgs

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

void setArgs (
  std.variant.VariantN!(32L)[] va,
  ParameterSpecialization[] psnList = null
);

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

Parameter specializations can be added if required. 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 = stmt.exec();
} while(!dr.done);

Type Mappings

See the MySQL/D Type Mappings tables

Parameters

NameDescription
va External list of Variants to be used as parameters
psnList any required specializations