title: How to prepare statements and bind parameters in Postgresql for C++
body: <p>I'm quite new to <code>C++</code> and know a little bit about <code>pqxx</code> library. What I want to implement is to prepare statements and bind parameters. In <code>PHP</code> I'm used to doing this in such a nice and concise manner:</p>
  
  <pre><code>$s = $db-&gt;prepare("SELECT id FROM mytable WHERE id = :id");
  $s-&gt;bindParam(':id', $id);
  $s-&gt;execute();
  </code></pre>
  
  <p>or using tokens:</p>
  
  <pre><code>$data = array();
  $data[] = 1;
  $data[] = 2;
  $s = $db-&gt;prepare("SELECT id FROM mytable WHERE id = ? or id = ?");
  $s-&gt;execute($data);
  </code></pre>
  
  <p>I tried to fugure out from pqxx <a href="http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/a00200.html" rel="noreferrer">documentation</a> how to implement this, but to me documentation looks like a mess and lacks short and simple examples (like I provided above). I hope someone can also provide such simple examples (or of comparable simplicity - without having to write some behemoth code) when dealing with <code>Postgresql</code> in <code>C++</code>.</p>