title: Processing feedback about duplicate rows on bulk insert
body: <p>I have a service that allows users to import multiple items at once besides filling the form, uploading the csv file where each row is representing an item - entity using an id that is set under an unique field in my mysql database (only one item with specific id can exist).</p>
  
  <p>When user finishes with the upload and csv processing, I would like to provide feedback about what items in their file already existed in the database. I decided to go with INSERT IGNORE, parsing the id's out of warnings (regex) and retrieving item information (SELECT) based on collected id's. Browsing the internet, I did not find the common solution for this so I would like to know if this approach is correct, specially when dealing with larger number of rows (500+).</p>
  
  <p>Base idea:</p>
  
  <pre><code>INSERT IGNORE INTO (id, name, address, phone) VALUES (x,xx,xxx,xxxx), (y,yy,yyy,yyyy), etc;
  
  SHOW WARNINGS;
  
  $warning_example = [0=&gt;['Message'=&gt;'Duplicate entry on '123456'...'], 1=&gt;['Message'=&gt;'Duplicate entry on '234567'...']];
  $duplicates_count = 0;
  foreach($warning_example as $duplicated_item) {
      preg_match('/regex_to_extract_id/', $duplicated_item['Message'], $result);
      $id[$duplicates_count] = $result;
      $duplicates_count++;
  }
  $duplicates_string = implode(',',$id);
  
  SELECT name FROM items WHERE id IN ($duplicates_string);
  </code></pre>
  
  <p>Also, what would be the simplest and most efficient regex for this task since the message structure is the same every time.</p>
  
  <pre><code>Duplicate entry '12345678' for key 'id'
  Duplicate entry '23456789' for key 'id'
  etc.
  </code></pre>