Module Mysql8.Prepared

Prepared statements with parameters. Consult the MySQL manual for detailed description and possible problems.

type stmt

Prepared statement

type stmt_result

Prepared query result (rowset)

val create : dbd -> string -> stmt

Create prepared statement. Placeholders for parameters are ? and \@param. Returned prepared statement is only valid in the context of this connection and can be reused many times during the lifetime of the connection.

val execute : stmt -> string array -> stmt_result

Execute the prepared statement with the specified values for parameters.

val execute_null : stmt -> string option array -> stmt_result

Same as execute, but with support for NULL values.

val affected : stmt -> int64
returns

Number of rows affected by the last execution of this statement.

val insert_id : stmt -> int64
returns

The rowid of the last inserted row.

val real_status : stmt -> int
returns

the error code for the last operation on this statement, 0 for success.

val fetch : stmt_result -> string option array option
returns

the next row of the result set.

val result_metadata : stmt -> result
returns

metadata on the statement's result set.

val close : stmt -> unit

Destroy the prepared statement