title: SQLSTATE[23000]: Integrity constraint violation error handling
body: <p>I know what the error means, and why it's occurring, meaning this is not a duplicate of the many topics covering State 23000. I'm using PDO to insert a duplicate record into a table that has a compound PK. I did this on purpose, in order to automatically cancel the insertion of any duplicated records in to this specific table.</p>
  
  <p>The error, <code>SQLSTATE[23000]: Integrity constraint violation</code>, is killing the script. Is there a way to set the warn level for this particular error, to literally tell it to shut up and carry on?</p>
  
  <p>I don't understand the purpose of having compound PKs if we can't allow them to work for us?</p>
  
  <p>I'm not very experienced with DB administration so you'll have to forgive me if I come across a bit 'it should work if I hit it with a hammer'.</p>
  
  <p><strong>Table Structure:</strong></p>
  
  <pre><code>CREATE TABLE `cart` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `userid` int(10) NOT NULL,
   `itemid` int(10) NOT NULL,
   UNIQUE KEY `id` (`id`),
   UNIQUE KEY `unique_records` (`userid`,`itemid`)
  ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1
  </code></pre>
  
  <p>Note the compound PK called 'unique records'.</p>
  
  <p>so I have this table:</p>
  
  <pre><code>| id | userid | itemid |
  |  1 |    175 |     12 |
  </code></pre>
  
  <p>And I execute this query:</p>
  
  <pre><code>    $insertItem = $db-&gt;query("
                                INSERT INTO cart (userid, itemid) 
                                VALUES (:userid, :itemid), 
                                array("userid"=&gt;"175", "itemid"=&gt;"12")
                              ");
  </code></pre>
  
  <p>Executing this query prompts this error: <code>SQLSTATE[23000]: Integrity constraint violation</code>.</p>
  
  <p>I fully understand why I'm getting this error - I just don't understand why it's killing my submission? I thought it should just keep working ignoring the fact that a few records weren't inserted because they were duplicates?</p>
  
  <p>Advice appreciated!</p>