title: PDO Unbuffered queries
body: <p>I'm trying to get into PDO details. So I coded this:</p>
  
  <pre><code>$cn = getConnection();
  
  // get table sequence
  $comando = "call p_generate_seq('bitacora')";
  $id = getValue($cn, $comando);
  
  //$comando = 'INSERT INTO dsa_bitacora (id, estado, fch_creacion) VALUES (?, ?, ?)';
  $comando = 'INSERT INTO dsa_bitacora (id, estado, fch_creacion) VALUES (:id, :estado, :fch_creacion)';
  $parametros = array (
      ':id'=&gt; (int)$id,
      ':estado'=&gt;1,
      ':fch_creacion'=&gt;date('Y-m-d H:i:s')
  );
  execWithParameters($cn, $comando, $parametros);
  </code></pre>
  
  <p>my getValue function works fine, and I get the next sequence for the table. But when I get into execWithParameters, i get this exception:</p>
  
  <blockquote>
    <p>PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in D:\Servidor\xampp_1_7_1\htdocs\bitacora\func_db.php on line 77</p>
  </blockquote>
  
  <p>I tried to modify the connection attributes but it doesn't work.</p>
  
  <p>These are my core db functions:</p>
  
  <pre><code>function getConnection() {
      try {
          $cn = new PDO("mysql:host=$host;dbname=$bd", $usuario, $clave, array(
                  PDO::ATTR_ERRMODE =&gt; PDO::ERRMODE_EXCEPTION,
              ));
  
          $cn-&gt;setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
          return $cn;
      } catch (PDOException $e) {
          print "Error!: " . $e-&gt;getMessage() . "&lt;br/&gt;";
          die();
      }
  }
  function getValue($cn, $comando) {
      $resul = $cn-&gt;query($comando);
          if (!$resul) return null;
          while($res = $resul-&gt;fetch()) {
              $retorno = $res[0][0];
              break;
          }
          return $retorno;
  }
  function execWithParameters($cn, $comando, $parametros) {
      $q = $cn-&gt;prepare($comando);
      $q-&gt;execute($parametros);
      if ($q-&gt;errorInfo() != null) {
          $e = $q-&gt;errorInfo();
          echo $e[0].':'.$e[1].':'.$e[2];
      }
  }
  </code></pre>
  
  <p>Somebody who can shed a light for this? PD. Please do not suggest doing autonumeric id, cause i am porting from another system.</p>