有没有办法 var_dump 当前活动的无缓冲查询
Is there a way to var_dump currently active unbuffered queries
TL;DR 我不是在问如何让错误消失,我不想再知道我可以使用 fetchAll()
and/or 打开缓冲查询。
关于此错误的另一个问题:
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.
ther are 无数关于此的帖子,它们很棒,但这不是我的兴趣。
我不只是想让错误消失,我想知道是否有办法确定哪些无缓冲查询仍然处于活动状态?
因为我只使用 MySQL,而我的应用程序只会 运行 和 MySQL,我当然可以
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
但这不是重点。
man page for pdo doesn't seem to have a method to do this, and the inTransaction()
方法不适用,因为我没有使用交易。
如果有帮助的话,所有查询都是准备好的语句,只要有准备好的 sql 就可以极大地帮助我查明哪个查询没有完全获取。
var_dumping PDO 对象产生了一个不太有用的结果:
object(PDO)#31 (0) { }
我的梦想是能够使用这样的东西:
var_dump($pdo->showActiveQueries());
这会 return 类似
array(2) {
[0]=> string(19) "SELECT foo FROM bar"
[1]=> string(21) "SELECT 2foo FROM 2bar"
}
我的理解是您一次只能执行一个无缓冲查询,所以如果是这种情况,难道不是 运行 在您收到错误之前的最后一个查询吗?原因?
如果您正在使用某种数据库抽象,您可以只获取最后一个 成功的 查询,这就是导致错误的查询。
您是否尝试过在创建新查询之前关闭 运行 的最后一个查询的游标? http://us.php.net/manual/en/pdostatement.closecursor.php
PDOStatement::closeCursor()
frees up the connection to the server so that other SQL statements may be issued, but leaves the statement in a state that enables it to be executed again.
TL;DR 我不是在问如何让错误消失,我不想再知道我可以使用 fetchAll()
and/or 打开缓冲查询。
关于此错误的另一个问题:
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.
ther
我不只是想让错误消失,我想知道是否有办法确定哪些无缓冲查询仍然处于活动状态?
因为我只使用 MySQL,而我的应用程序只会 运行 和 MySQL,我当然可以
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
但这不是重点。
man page for pdo doesn't seem to have a method to do this, and the inTransaction()
方法不适用,因为我没有使用交易。
如果有帮助的话,所有查询都是准备好的语句,只要有准备好的 sql 就可以极大地帮助我查明哪个查询没有完全获取。
var_dumping PDO 对象产生了一个不太有用的结果:
object(PDO)#31 (0) { }
我的梦想是能够使用这样的东西:
var_dump($pdo->showActiveQueries());
这会 return 类似
array(2) { [0]=> string(19) "SELECT foo FROM bar" [1]=> string(21) "SELECT 2foo FROM 2bar" }
我的理解是您一次只能执行一个无缓冲查询,所以如果是这种情况,难道不是 运行 在您收到错误之前的最后一个查询吗?原因?
如果您正在使用某种数据库抽象,您可以只获取最后一个 成功的 查询,这就是导致错误的查询。
您是否尝试过在创建新查询之前关闭 运行 的最后一个查询的游标? http://us.php.net/manual/en/pdostatement.closecursor.php
PDOStatement::closeCursor()
frees up the connection to the server so that other SQL statements may be issued, but leaves the statement in a state that enables it to be executed again.