title: PDO::lastInsertId resets after SELECT in PHP 7.2
body: <p>We're upgrading our application to PHP 7.2 (currently at 7.2.7) from PHP 5.5.9 and stumbled upon the following problem.</p>
  
  <p>When executing an INSERT query and then immediately running lastInsertId, the value it returns is correct. But if a SELECT query is executed in between, lastInsertId returns 0. This did not happen in PHP 5.5.9. </p>
  
  <p>Our MySQL version is 5.7.22, but I don't think that's related since we have the same MySQL version on another machine with PHP 5.5 and we don't have the problem there.</p>
  
  <p>If you run "SELECT LAST_INSERT_ID();" as a raw query (through PDO) the result you get is correct, so this seems to be a bug with PDO's lastInsertId. </p>
  
  <p>Here is an example code snippet which you can use to reproduce the problem:</p>
  
  <pre><code>&lt;?php
  
  $username = "username";
  $password = "password";    
  
  $pdo = new PDO("mysql:host=127.0.0.1;port=3306;dbname=test_db", $username, $password);
      $pdo-&gt;query("CREATE TABLE IF NOT EXISTS `test_table` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `random_field` int(11) NOT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;");
      $st = $pdo-&gt;query("INSERT INTO test_table(random_field) VALUES (" . rand(1, 100000) . ")");
      if($st){
          echo "last_insert_id: " . $pdo-&gt;lastInsertId() . "\n";
          $pdo-&gt;query("SELECT 1 + 1");
          echo "last_insert_id: " . $pdo-&gt;lastInsertId() . "\n";
      }
      else{
          var_dump($pdo-&gt;errorInfo());
      }
  </code></pre>