79118457

Date: 2024-10-23 14:53:41
Score: 1
Natty:
Report link

This is a little late but for people looking at this now and in the future. I think now you would want to do something like this Documentation

Basically instead of prepared statements you would still do the $1 , $2, ... stuff in a query string and then you would build a pqxx::params and then pass that with the query.

int values[] = {1,2,3};
std::string query = "INSERT into mytable (a, b, c) VALUES ($1, $2, $3)";
pqxx::params p;

for (int i = 0; i < num_values; i++) {
  p.append(values[i])
}
pqxx::nontransaction ntxn(c);
ntxn.exec(query, p);

and your c would be your pqxx::connection. Note: This code my not be exactly syntatically correct but this is the general idea I think.

Reasons:
  • Blacklisted phrase (1): this Document
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Shawnz99