myxql v0.1.1 MyXQL.Query View Source

Query struct returned from a successfully prepared query.

Its public fields are:

  • :name - The name of the prepared statement;
  • :num_params - The number of parameter placeholders;
  • :ref - A reference used to identify prepared queries;
  • :statement - The prepared statement

Once a query is prepared with MyXQL.prepare/4, the returned query will have its ref field set to a reference. When MyXQL.execute/4 is called with the prepared query, it always returns a query. If the ref field in the query given to execute and the one returned are the same, it means the cached prepared query was used. If the ref field is not the same, it means the query had to be re-prepared.

Named and Unnamed Queries

Named queries are identified by the non-empty value in :name field and are meant to be re-used.

Unnamed queries, with :name equal to "", are automatically closed after being executed.

Link to this section Summary

Link to this section Types

Link to this type

t() View Source
t() :: %MyXQL.Query{
  name: iodata(),
  num_params: non_neg_integer(),
  ref: reference(),
  statement: iodata()
}