title: Getting row data of inserted row (Mysql, PHP, mysqli)
body: <p>I need to get back the postid (auto-incrementing PK) of a row when i insert it. </p>
  
  <p>I am currently using this to get it</p>
  
  <pre><code>//get postid to return
  if($result = $db -&gt; query('SELECT postid FROM posts WHERE title = \''.$title.'\' LIMIT 1')){
          $row = $result-&gt;fetch_assoc();
          $json['postid']  = $row['postid'];
          $result-&gt;free();
  </code></pre>
  
  <p>where $title is the title name of the newly-inserted post. </p>
  
  <p>Is there part of the mysqli class that will allow me to do this in one query?? Does $db -> query() return any information that will make this simpler and more secure? </p>
  
  <p>I have tried looking through the mysqli documentation, but I could not find what i wanted. I'm sure it is there somewhere.</p>
  
  <p>Multiple titles will screw this up, and although they are not allowed, you cant be too safe</p>