title: Using PDO to set a variable from a MAX query
body: <p>I want to set a variable $item_id from the result of this query, how do I do it?</p>
  
  <p>SELECT FROM item (MAX(item_id) + 1));</p>
  
  <p>I have tried this code, but it isn't giving me a result:</p>
  
  <pre><code>$sql = "SELECT FROM item (MAX(item_id) + 1));";
  $statement = $db-&gt;prepare($sql);
  $statement-&gt;execute($sql);
  $item_id = $statement-&gt;fetchColumn();
  </code></pre>
  
  <p>My database connection is named $db and is housed in a common.php file, and all other queries are working, I've tried numerous options but am not having a win.</p>