Answer the question
In order to leave comments, you need to log in
PDO and stored procedures. Why does not it work?
Hello.
There is a mysql database. There are three stored procedures in it.
The first procedure returns us an ID by which the second procedure looks for something in the database and returns a new ID, which is passed to the third procedure
Something like this in general
$sql=new PDO("here_connect_to_base");
$stm1=$sql->prepare('CALL proc1');
$stm1->execute();
$res1=$stm1->fetchAll(PDO::FETCH_ASSOC);
$stm2=$sql->prepare('CALL proc2(:id)');
$stm2->execute(array(':id'=>$res1[0]['id']));
$res2=$stm2->fetchAll(PDO::FETCH_ASSOC);
$stm3=$sql->prepare('CALL proc3(:id)');
$stm3->execute(array(':id'=>$res2[0]['id']));
$res3=$stm3->fetchAll(PDO::FETCH_ASSOC);
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.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question