Skip to content
Georg Richter edited this page Jul 3, 2022 · 23 revisions

Prepared Statement API Reference

A prepared statement or a parameterized statement is used to execute the same statement repeatedly with high efficiency. The prepared statement execution consists of two stages: prepare and execute.

  • At the prepare stage a statement template is sent to the database server. The server performs a syntax check and initializes server internal resources for later use.
  • During execute the client binds parameter values and sends them to the server. The server creates a statement from the statement template and the bound values to execute it using the previously created internal resources.

A prepared statement can be executed repeatedly. Upon every execution the current value of the bound variable is evaluated and sent to the server. The statement is not parsed again. The statement template is not transferred to the server again.

The MariaDB server supports using anonymous, positional placeholder with ?(question mark).

Opposed to the text protocol where all values are transferred as strings, prepared statements use the binary protocol where all values beside strings are transferred in their native format.

API Functions

Clone this wiki locally