title: php postgresql pdo copy from stdin
body: <pre><code>COPY table_name ( field1, field2, field3) FROM STDIN CSV;
  1,2,&quot;q w&quot;
  3,4,&quot;a s&quot;
  5,6,d
  \.
  </code></pre>
  <p>How to execute this query by PDO ?</p>
  <h3>Update:</h3>
  <p>Problem is PDO driver executes this query as statement.<br />
  For example, if you paste it into pgAdmin, it throws an error.<br />
  I need execute it in <code>psql</code>:</p>
  <pre class="lang-none prettyprint-override"><code>C:\Users\User&gt;psql -e -h localhost -U postgres db_name
  psql (9.1.2)
  db_name=# COPY table_name ( field1, field2, field3) FROM STDIN CSV;
  COPY table_name ( field1, field2, field3) FROM STDIN CSV;
  Enter data to be copied followed by a newline.
  End with a backslash and a period on a line by itself.
  &gt;&gt; 1,2,&quot;q w&quot;
  &gt;&gt; 3,4,&quot;a s&quot;
  &gt;&gt; 5,6,d
  &gt;&gt; \.
  </code></pre>