Error in PDO query

5

I am creating a registration page where I have several tabs, according to the structure below:

<div> Aba 1 </div>
<div> Aba 2 </div>
<div> Aba 3 </div>
<div> Aba 4 </div> e assim vai...

Inside each tab I have a sql query using PDO, but when I get on tab 4 the following error message appears:

  

Array ([0] => 00000 [1] => 2014 [2] => Can not execute queries while other unbuffered queries are active) Consider using PDOStatement :: fetchAll () Alternatively, if your code is

I've already activated and deactivated the PDO :: MYSQL_ATTR_USE_BUFFERED_QUERY but nothing resolves ...

* My Query *

<tbody>
    <?php
        $sql5 = "CALL sp_FornecedorAnalitico_Selecionar(:codigoFornecedor, :tipo)";
        $stmt5 = $conexao_oo->conn->prepare($sql5);
        $stmt5->bindValue(":codigoFornecedor", $_GET['codForn']);
        $stmt5->bindValue(":tipo", 5);
        $stmt5->execute();
        $dadosFornecedor5 = $stmt5->fetchAll(PDO::FETCH_OBJ);
        print_r($stmt5->errorInfo());
        foreach ($dadosFornecedor5 as $pedido) {
            echo "<tr>";
                echo "<td>".$pedido->codSol."</td>";
                echo "<td>".$pedido->numPedido."</td>";
                echo "<td>".$pedido->solicitante."</td>";
                echo "<td>".$pedido->empresa."</td>";
                echo "<td>".$pedido->setor."</td>";
                echo "<td>".$pedido->tipo."</td>";
                echo "<td>".$pedido->prevEntrega."</td>";
                echo "<td></td>";
                echo "<td>".$pedido->condicao."</td>";
                echo "<td>".$pedido->status_sc."</td>";
                echo "<td>".$pedido->valor_total."</td>";
                echo "<td><a target='_blank' title='Visualizar Itens da Solicitação' href='visualizar_sc.php?cod_solicitacao=".$valor->codScompra."'><img src='images/icons/search.png'></a></td>";
                echo "</tr>";
        }
    ?>
</tbody>
    
asked by anonymous 04.02.2015 / 15:09

1 answer

3

Based on this SOen response and manual , when you have to execute multiple queries in sequence, close the course to release the resources of the server using closeCursor() after fetchAll()

    $stmt5->execute();
    $dadosFornecedor5 = $stmt5->fetchAll(PDO::FETCH_OBJ);
    $stmt5->closeCursor();
    
04.02.2015 / 15:38