Loading...
Searching...
No Matches
pqxx::placeholders< COUNTER > Class Template Reference

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.
std::string | get () const
| Read the current placeholder text, as a `std::string`.
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.

## Detailed Description

template<typename COUNTER = unsigned int>
class pqxx::placeholders< COUNTER >

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.

## Member Function Documentation

## get()

template<typename COUNTER = unsigned int>

std::string pqxx::placeholders< COUNTER >::get | ( |  | ) | const

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.

## view()

template<typename COUNTER = unsigned int>

constexpr zview pqxx::placeholders< COUNTER >::view | ( |  | ) | const &

inline constexpr noexcept

Read an ephemeral version of the current placeholder text.

Warning
  Changing the current placeholder number will overwrite this. Use the view immediately, or lose it.

## Member Data Documentation

## max_params

template<typename COUNTER = unsigned int>

constexpr unsigned int pqxx::placeholders< COUNTER >::max_params

inline static constexpr

Initial value:
{
(std::numeric_limits<COUNTER>::max)()}

Maximum number of parameters we support.

The documentation for this class was generated from the following file:

- /build/libpqxx-dRO3di/libpqxx-7.10.0/include/pqxx/params.hxx