mkosmosports Posted November 2, 2007 Share Posted November 2, 2007 Hey, I want to issue multiple queries in my script using PDO. All of of these queries will either retrieve one row with multiple columns or one row with one column, so I am using either fetch or fetchColumn to get the data. Now, I ran into an error message telling me: "General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll()." If there is only one row being retrieved (and I know this for sure), how is it that unbuffered queries are still active? And whats the most effective way to get around this? I can use fetchAll or loop with fetchColumn or call PDOStatement->closeCursor(); after each query data retrieval statement. Anyone else encounter this? Any advice? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/75722-solved-issuing-multiple-queries-with-pdo/ Share on other sites More sharing options...
sKunKbad Posted November 2, 2007 Share Posted November 2, 2007 Ya know, not showing everyone what you did to fix this doesn't help people in the future who may have the same question. In my case, when using PDO with multiple queries, I always had to make sure that at the end of each query the object was deleted. For instance: $pdo1 = $pdo->query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); $picRow = $pdo1->fetch(PDO::FETCH_ASSOC); extract($picRow); echo " <title>Tips & Tricks - Tip # {$_GET['tip']} - $tipTitle</title> <meta name='description' content='$tipBlurb' />"; $pdo1 = null; //HERE $pdo5 = $pdo->prepare("SELECT * FROM tipsntricks WHERE tipType = '$tipCat' ORDER BY tipNum DESC"); $pdo5->execute(); $num_rows = count($pdo5->fetchAll()); if ($num_rows != 0){ echo " <li class='prodcat'><h3>" . ucfirst($tipCat) . "</h3> <ul>"; foreach ($pdo->query("SELECT * FROM tipsntricks WHERE tipType = '$tipCat' ORDER BY tipNum DESC") as $row) { echo "<li><a href='http://www.whatever.tv/tips/". $row['tipNum'] . ".php5'>" . $row['tipTitle'] . " </a></li>"; } echo " </ul> </li>"; } $pdo5 = null; //HERE Quote Link to comment https://forums.phpfreaks.com/topic/75722-solved-issuing-multiple-queries-with-pdo/#findComment-383284 Share on other sites More sharing options...
mkosmosports Posted November 2, 2007 Author Share Posted November 2, 2007 Youre right skunkbad, my bad, I was too excited to continue coding.. My solution was the same as the one you suggested. Just making sure that after every query issued, I delete that query object, thus freeing up the resources needed to make the next query. Quote Link to comment https://forums.phpfreaks.com/topic/75722-solved-issuing-multiple-queries-with-pdo/#findComment-383309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.