使用 mysql_unbuffered_query 的多个连接
是否可以通过打开第二个连接来绕过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 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.