title: Best practice for verifying uniqueness in database?
body: <p>I'm creating a database which requires several fields to be unique, and was wondering which method is <em>least expensive</em> in terms of checking that uniqueness?</p>
  
  <ol>
  <li>Query the database with a mysqli() call to check if a value exists?</li>
  <li>Use PHP to download a file of all entries, then check that file and delete afterwards</li>
  <li>Set columns to "Unique" index</li>
  </ol>
  
  <p>If the best option (which I'm assuming it is) is to set the columns to unique, then how do you go about handling the error that gets thrown when the value already exists without breaking out of the function? Or is that even possible?</p>