Skip to content

Commit

Permalink
Fix placeholders example.
Browse files Browse the repository at this point in the history
Fixes #557.
  • Loading branch information
jtv committed Apr 3, 2022
1 parent de27886 commit 134f593
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- More strictness in `header-pre.hxx`/`header-post.hxx` checking.
- Disallow nesting of `ignore-deprecated` blocks.
- Deprecate `exec` functions' `desc` parameter.
- Fix `placeholders` documentation. (#557)
7.7.2
- Fix up damage done by auto-formatting.
7.7.1
Expand Down
20 changes: 12 additions & 8 deletions include/pqxx/doc/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ Let's say you've got some complex code to generate the conditions for an SQL
"WHERE" clause. You'll generally want to do these things close together in
your, so that you don't accidentally update one part and forget another:

// Start a new parameter placeholder.
name.next();
// Extend the query text, using the current placeholder.
clause += " AND x = " + name.get();
// Add the parameter value.
values.append(my_x);

Easy, right?
if (extra_clause)
{
// Extend the query text, using the current placeholder.
query += " AND x = " + name.get();
// Add the parameter value.
values.append(my_x);
// Move on to the next placeholder value.
name.next();
}

Depending on the starting value of `name`, this might add to `query` a fragment
like "` AND x = $3`" or "` AND x = $5`".

0 comments on commit 134f593

Please sign in to comment.