dsy1971 2011-02-15 22:25
浏览 50

too long

At the top of my php page, I include a connection script called by:

include("connector.php")

Connector.php

<?php

    try
    {
        $db = new PDO('mysql:host=localhost;dbname=DB', 'USER', 'PW');
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }

    catch (PDOException $e)
    {
        echo $e->getMessage();
    }
?>

I then make all subsequent calls on my pages as necessary. On one page in particular however, I initially make a call into a MySQL stored procedure:

$stmt = $db->prepare("CALL Procedure(:id)");
$stmt->bindParam(':id', $id);
$stmt->execute();

while($row=$stmt->fetch()) {
    echo "<tr>
        <td>".$row['ID']."</td>
        <td>".$row['NAME']."</td>
        </tr>";
}

There is no issue with my stored procedure but down the page when I try and make any subsequent calls, I get the usual PDO Mysql unbuffered queries error:

Fatal error: Uncaught exception 'PDOException' with message '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 C:\page.php:261 Stack trace: #0 C:\page.php(261): PDOStatement->execute(Array) #1 {main} thrown in C:\page.php on line 261

Yes, I have tried using FetchAll, and NO I do not want to use the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute as we may switch off MySQL at a later point in time and I do not wish to rebuild based on every DB (not to mention even when I did include it did not work).

Any ideas why this might be happening? I could 'include' the connector.php file before every DB call but that seems repetitive and I'd have to $db->NULL every statement.

Note: this seems to only affect pages with calls into stored procedures. Any ideas?

Note: This is being run on a Windows machine with XAMPP 1.7.3 running Apache 2.2.14, PHP 5.3.1

  • 写回答

2条回答 默认 最新

  • dongqian5569 2011-02-15 22:31
    关注

    Apparently that is caused by a bug in PHP and lack of support for stored procedures on Windows machines.

    Please try the following: http://bugs.php.net/bug.php?id=39858

    Looking at the very last comment: 1221253320 it seems to have been fixed, you can try update your PHP To the latest version. 5.3

    my advice: If your using a pre packaged "server" kit such as xampp then you should scrap that all together, partition 2GB of your hard drive using the Storage Extender in Storage Management, Install MySql,PHP,Apache seperatly and then configure them.

    use that latest snapshot of PHP and the latest MySql Distro, Migrate your application and database to the new install, kick your computer and it should run fine.

    I would bet that it could be down to the MySql Client Libs as well, Upgrade them

    Some related links im coming across:

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?