dongwen2162 2011-05-12 21:28
浏览 48
已采纳

使用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."

  • 写回答

1条回答 默认 最新

  • doulu8415 2011-05-18 20:12
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败