libpqxx
The C++ client library for PostgreSQL
|
Generate parameter placeholders for use in an SQL statement. More...
Public Member Functions | |
constexpr zview | view () const &noexcept |
Read an ephemeral version of the current placeholder text. More... | |
std::string | get () const |
Read the current placeholder text, as a std::string . More... | |
void | next () & |
Move on to the next parameter. | |
COUNTER | count () const noexcept |
Return the current placeholder number. The initial placeholder is 1. | |
Static Public Attributes | |
static constexpr unsigned int | max_params |
Maximum number of parameters we support. More... | |
Generate parameter placeholders for use in an SQL statement.
When you want to pass parameters to a prepared statement or a parameterised statement, you insert placeholders into the SQL. During invocation, the database replaces those with the respective parameter values you passed.
The placeholders look like $1
(for the first parameter value), $2
(for the second), and so on. You can just write those directly in your statement. But for those rare cases where it becomes difficult to track which number a placeholder should have, you can use a placeholders
object to count and generate them in order.
|
inline |
Read the current placeholder text, as a std::string
.
This will be slightly slower than converting to a zview
. With most C++ implementations however, until you get into ridiculous numbers of parameters, the string will benefit from the Short String Optimization, or SSO.
|
inlineconstexprnoexcept |
Read an ephemeral version of the current placeholder text.
|
inlinestaticconstexpr |
Maximum number of parameters we support.