title: PHP, Postgres help using RETURNING
body: <p>I think I understand how PostgreSQL and RETURNING works - I've found many, many resources. If I'm catching on, it would look something like</p>
  
  <pre><code>"INSERT INTO table (column2, column3) VALUES ('value1', 'value2') RETURNING id;"
  </code></pre>
  
  <p>However, I can't find anything that helps me access this via PHP. When I thought I figured it out, I tried</p>
  
  <pre><code>$new_id = pg_query($dbc, "INSERT INTO table (column2, column3) ".
  "VALUES ('value1', 'value2') RETURNING id;");
  return $new_id;
  </code></pre>
  
  <p>But it returns NULL. I also tried executing and declaring the variable separately with one query. After looking for hours for the solution, I've settled on a max(id) SELECT statement/function, but it's still bothering me. Any help is greatly appreciated.</p>
  
  <p>I'm using Postgres 8.4 and PHP 5.3.</p>