title: PHP mysqli: Insert row or return id if unique conflict
body: <p>I have a table with weight values:</p>
  
  <pre><code>TABLE_WEIGHT
      WEIGHT_ID bigint(20) NOT NULL PRIMARY KEY AUTO_INCREMENT,
      WEIGHT float NOT NULL UNIQUE
  </code></pre>
  
  <p>And i insert values:</p>
  
  <pre><code>$query = "INSERT INTO TABLE_WEIGHT (WEIGHT) VALUES(100)";
  
  if ($stmt = $this-&gt;mysqli-&gt;prepare($query)) : 
      if (!stmt-&gt;execute()) : 
          // some error
      else :
          // alright
      endif;
  endif;
  </code></pre>
  
  <p>The first time i do this i will have no problem. If i do that the second time the value 100 already exists. Is there a way to now just get the id of the conflicted row without the need of a new select statement?</p>