title: PHP PDO does not throw exception on duplicate key insert
body: <p>I have a strange problem with PDO not throwing an exception when a duplicate value is inserted. In this case I did expect an error.</p>
  
  <p>The relevant code:</p>
  
  <pre><code>try
  {
    $db_conn = new PDO("mysql:host=".$config["database"]["hostname"].";charset=utf8", $config["database"]["username"], $config["database"]["password"], []);
    $db_conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $db_conn-&gt;exec(file_get_contents("some_file_with_data.sql");
  }
  catch(Exception $e)
  {
    // PDOException extends RuntimeException extends Exception so exceptions should be catched here
    // however for the duplicate key entry it will not throw an exception
  }
  </code></pre>
  
  <p>The file with SQL data contains multiple inserts like this:</p>
  
  <pre><code>INSERT INTO `a` (`b`, `c`) VALUES
    (1, 1),
    (2, 2),
    (3, 2);
  
  INSERT INTO `a` (`b`, `c`) VALUES
    (1, 1);
  </code></pre>
  
  <p>The field <code>b</code> in table <code>a</code> is set to being the primary key. When I insert the exact same data in the exact same structure using phpMyAdmin I get this error: <code>#1062 - Duplicate entry '65533' for key 'PRIMARY'</code></p>
  
  <p>Why does PDO not throw an error in this case? Even when I set the error mode to exception?</p>
  
  <p>Edit:
  This is the table structure used for this specific table</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `a` (
    `b` smallint(5) unsigned NOT NULL,
    `c` smallint(5) unsigned NOT NULL,
    PRIMARY KEY (`b`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  </code></pre>