PHP PDO call Procedure and then select from temporary table

Asked

Viewed 141 times

0

I have a protocol that creates a temporary table and I need to select it right after. I’m using Pdo and always returns some error, in my last code gives error 500 and do not know where to go.

$proc = $this->conn->prepare("CALL proc_busca_disponivel(?)");
    $proc->bindParam(1, $id_evento, PDO::PARAM_INT, 4000);
    $proc->execute();
    $proc->closeCursor();

    $stmt = $this->conn->prepare("SELECT * from LISTA_DISPONIVEL");
    $stmt->execute();

    $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);

    var_dump($res);

I am not the one making the database. If I run the queries in the mysql panel, it returns perfectly, so I conclude that I am missing in Pdo. I also activated and deactivated Pdo buffler, as I had indicated this in the error in other attempts to create the code, but so far I did not exceed error 500.

$this->conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); //ou false dá no mesmo
  • When you close the cursor $proc->closeCursor(); PDO releases the buffer containing the result of your query. $proc->closeCursor(); should be used if you want to repeat same query.

  • Apart from the $proc->closeCursor(); returns the buffle problem, but setting to false falls into error 500.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.