title: Can I use PDO to run multiple SQL queries and retrieve the number of rows affected for each statement?
body: <p>Here's what I've got so far:</p>
  
  <pre><code>/**
   * @param PDO $db
   * @param string $file
   */
  function run_sql_file($db, $file) {
      $sql = file_get_contents($file);
      try {
          $affected = $db-&gt;exec($sql);
          println("$affected row(s) affected");
      } catch(PDOException $e) {
          exitmsg($e-&gt;getMessage());
      }
  }
  </code></pre>
  
  <p>It does seem to run all the queries, but it always give me back "0 rows affected". Is there a way to get the number of rows affected for each statement? Preferably along with the associated query, and any error messages and warnings.</p>