Function SafePrepared.this

Constructor. You probably want prepare instead of this.

ref this (
  const(char[]) sql,
  PreparedStmtHeaders headers,
  ushort numParams
) @safe;

Call mysqln.safe.connection.prepare instead of this, unless you are creating your own transport bypassing Connection entirely. The prepared statement must be registered on the server BEFORE this is called (which mysqln.safe.connection.prepare does).

Internally, the result of a successful outcome will be a statement handle - an ID - for the prepared statement, a count of the parameters required for execution of the statement, and a count of the columns that will be present in any result set that the command generates.

The server will then proceed to send prepared statement headers, including parameter descriptions, and result set field descriptions, followed by an EOF packet.