title: MySQL Insert: Test first?
body: <p>As an example, when inserting a record into a table with a unique index, is it best to test first? <em>e.g.</em>, </p>
  
  <pre><code>$mysqli-&gt;query('SELECT email FROM tblUser WHERE email = 'foo@bar.org');
  </code></pre>
  
  <p>then make sure 0 rows are returned, <em>then</em> do the insert? </p>
  
  <pre><code>$mysqli-&gt;query('INSERT INTO tblUser ...');
  </code></pre>
  
  <p>Or is it better to just skip the test and handle the error in the event there's a duplicate entry? </p>
  
  <p>THANKS!</p>