libpqxx
7.7.0
|
Generate parameter placeholders for use in an SQL statement. More...
#include <params.hxx>
Public Member Functions | |
placeholders () | |
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. More... | |
COUNTER | count () const noexcept |
Return the current placeholder number. The initial placeholder is 1. More... | |
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.
pqxx::placeholders< COUNTER >::placeholders | ( | ) |
|
noexcept |
Return the current placeholder number. The initial placeholder is 1.
std::string pqxx::placeholders< COUNTER >::get | ( | ) | const |
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.
void pqxx::placeholders< COUNTER >::next | ( | ) | & |
Move on to the next parameter.
References pqxx::check_cast(), and pqxx::string_traits< TYPE >::into_buf().
|
noexcept |
Read an ephemeral version of the current placeholder text.
|
static |
Maximum number of parameters we support.