title: MySQL and the chance of the wrong id being returned by LAST_INSERT_ID()
body: <p>From what I have read <code>LAST_INSERT_ID()</code> retrieves the id of the last insert statement to run. If that the last insert statement run on your connection or the last insert run on the database for all connections? I guess what I am trying to ask is: on a busy database driven website what are the chances the following code would return the wrong id, and is there a method to prevent that other then locking the database?</p>
  
  <pre><code>INSERT INTO example (string) VALUE ('something');
  SELECT LAST_INSERT_ID();
  </code></pre>
  
  <p>Would PHP's <code>mysql_insert_id()</code> be a better solution, or should I just query for data that was just inserted and grab id that way?</p>