title: Alternative to "PDO::lastInsertId" / "mysql_insert_id"
body: <p>I always hear that using "lastInsertId" (or mysql_insert_id() if you're not using PDO) is evil. In case of triggers it obviously is, because it could return something that's totally not the last ID that your INSERT created.</p>
  
  <pre><code>$DB-&gt;exec("INSERT INTO example (column1) VALUES ('test')");
  // Usually returns your newly created ID.
  // However when a TRIGGER inserts into another table with auto-increment:
  // -&gt; Returns newly created ID of trigger's INSERT
  $id = $DB-&gt;lastInsertId();
  </code></pre>
  
  <p>What's the alternative?</p>