dpdt79577 2014-08-19 06:35
浏览 51
已采纳

关闭语句后mysqli + xdebug断点导致许多警告

I have a piece of code like this:

$conn = new mysqli($host, $username, $passwd, $dbname);

...

$stmt = $conn->prepare('SELECT ...');
$stmt->bind_param(...);
$stmt->execute();
$stmt->bind_result(...);
while($stmt->fetch())
{
    // do something here
}
$stmt->close();

...

// do something more here that has absolutely nothing to do with $stmt

This works perfectly fine. I get the results I expected, there are no errors or anything that is not supposed to happen.

But if I set a break point (Xdebug 2.2.5 / 2.2.6 / 2.2.8 / 2.3.2 and PHP 5.5.3 / 5.5.15 / 5.6.0 / 5.6.6 / 5.6.10) to a line after $stmt->close();, I get many warnings like

Property access is not allowed yet

or

Couldn't fetch mysqli_stmt

I thought I missed to close another mysqli statement, but I get all results. There seems to be just no problem in my code...

Is there a way to get rid of this wrong warnings?

Update: This problem still exist in PHP 7.0.1 / Xdebug 2.4.0 RC3.

  • 写回答

5条回答 默认 最新

  • doutou1922 2014-08-19 06:35
    关注

    There are some similar issues reported
    http://bugs.xdebug.org/view.php?id=900
    https://bugs.php.net/bug.php?id=60778

    One way to get rid of this messages is to add

    unset($stmt);
    

    after closing the statement and before the breakpoint. If this does not help, you should also add

    unset($connection);
    

    after closing the connection as mentioned by @Martin in the comments.

    This does not solve the problem itself, but let you go on with your work until this may be fixed some time.

    EDIT: Now there is also a reported issue :)

    EDIT: This seems to be a bug in the MySQLi driver as reported here.

    EDIT: Looks like this bug does not appear if you use PDO. So this is maybe an other reason to switch to PDO.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么