title: Why PDO Exception Error Not Caught?
body: <p>I have a PHP script with two deliberate typo mistakes in the statement for an SQL query:</p>
  
  <pre><code>try
  {
   $stmt = $dbh-&gt;prepare("SELECT COUNT(*) FROM Product WHERE non-existent_column=?");
   $stmt-&gt;blindValue(1, $id, PDO::PARAM_INT);
   $stmt-&gt;execute();
   $row = $stmt-&gt;fetchColumn();
  }
  catch(PDOException $err)
  {
   var_dump($err-&gt;getMessage());
   var_dump($dbh-&gt;errorInfo());
  }
  </code></pre>
  
  <p>However, the script does not catch the error even after setting attribute to <code>PDO::ERRMODE_EXCEPTION</code>. What am I missing here?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This is the full script. The second typo <code>blindValue</code> has been reverted back. The error remains uncaught:</p>
  
  <pre><code>&lt;?php
  
  $user= "user";
  $password = "password";
  $dsn = "mysql:dbname=Catalogue;host=localhost";
  $dbh = new PDO($dsn, $user, $password);
  $dbh-&gt;setAttribute(PDO::ERRMODE_EXCEPTION); 
  $id = 1000;
  
  try
  {
   $stmt = $dbh-&gt;prepare("SELECT COUNT(*) FROM Product WHERE non-existent_column=?");
   $stmt-&gt;bindValue(1, $id, PDO::PARAM_INT);
   $stmt-&gt;execute();
   $row = $stmt-&gt;fetchColumn();
  }
  catch(PDOException $err)
  {
   echo "caught";
   var_dump($err-&gt;getMessage());
   var_dump($dbh-&gt;errorInfo());
   exit();
  }
  
  var_dump($stmt);
  var_dump($row);
  echo "uncaught";
  exit();
  
  ?&gt;
  </code></pre>