使用 mysql_unbuffered_query 的多个连接

发布于 2024-11-06 21:11:34 字数 983 浏览 0 评论 0原文

是否可以通过打开第二个连接来绕过 mysql_unbuffered_query() 一次运行一个查询的限制?

例如,以下代码给我错误:

mysql_select_db(): 调用函数时没有首先从先前的无缓冲查询中获取所有行

        $feedData =  mysql_unbuffered_query($sql, $this->_unbufferedDbManager->db->connection);

        while ($record = mysql_fetch_assoc($feedData)) {
            File::fputcsv($this->_fileHandle, $record, $this->delimiter, $this->enclosure);       

            $sql = "UPDATE   transactions
                    SET      feed_transmit_date = '$this->today'
                    WHERE    transaction_id = " . $record['transaction_id'];
            $this->dbManager->DbQuery($sql);

            print_r($this->_unbufferedDbManager->db->connection);
            print_r($this->dbManager->db->connection);
        }

最后输出的两个 print_r() : 资源 id #637Resource id #639

DbManager 是一个旧的 pear 数据访问层

注意:我本来会使用 mysql_unbuffered_query 标签,但我最近打开了一个赏金,使我低于“创建新标签权限”。

Is it possible to get around mysql_unbuffered_query()'s limitation of having one query running at a time by opening a second connection?

For example, the following code is giving me the error:

mysql_select_db(): Function called without first fetching all rows from a previous unbuffered query

        $feedData =  mysql_unbuffered_query($sql, $this->_unbufferedDbManager->db->connection);

        while ($record = mysql_fetch_assoc($feedData)) {
            File::fputcsv($this->_fileHandle, $record, $this->delimiter, $this->enclosure);       

            $sql = "UPDATE   transactions
                    SET      feed_transmit_date = '$this->today'
                    WHERE    transaction_id = " . $record['transaction_id'];
            $this->dbManager->DbQuery($sql);

            print_r($this->_unbufferedDbManager->db->connection);
            print_r($this->dbManager->db->connection);
        }

The two print_r()'s at the end output:
Resource id #637Resource id #639

DbManager is an old pear data access layer

Note: I would have used a mysql_unbuffered_query tag, but I recently opened a bounty that put me below the "create new tags privilege."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风尘浪孓 2024-11-13 21:11:34

根据 PMV 的建议,我正在写这个答案。总之,这是不同数据库类使用相同连接的问题,即使它们报告了不同的资源 ID。有关更多信息,请参阅问题的评论。

On PMV's suggestion I'm writing this answer. In summary, it was an issue of the different database classes using the same connection even though they reported different resource ids. See the question's comments for more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文