title: Nesting LAST_INSERT_ID() in a PDO prepared statement?
body: <p>Using PHP with MySQL and PDO prepared statements, I would like to mimic an opaque id in a simple, safe and efficient way. The idea is to add a random value to the current value of LAST_INSERT_ID.</p>
  
  <pre><code>INSERT INTO table 
  SET id = LAST_INSERT_ID( LAST_INSERT_ID() + FLOOR(1 + (RAND() * 99)) ), 
  text = ?,
  ...
  </code></pre>
  
  <p>The outer expression sets the id, the inner call gets the current value and modifies it. This works as expected when I test it with the Sequel Pro client. However, in the real script with a prepared statement the last insert id does not get updated/saved. So, I do get random ids, but they are not added up.</p>
  
  <p>What am I missing?</p>