douzhi2012 2019-04-26 16:27
浏览 48

为什么mysql在PHP中调用过程后关闭数据库连接时报告“中止连接”

I am running a server on Ubuntu 16.04 LTS with PHP 7.0 and MySQL 5.7.25. When running code snippet A MySQL logs "[Note] Aborted connection 23345 to db" upon trying to close the connection. This only happens when calling the stored procedure as seen in snippet A but not when directly executing the query as shown in snippet B.

Snippet A
<?php

    $database = new mysqli( 'localhost' , 'user' , 'test' , 'database' );

    $result = $database->query("CALL any_call();"); // returns true

    $result->close();

    $database->close();

?>
Snippet B
<?php

    $database = new mysqli( 'localhost' , 'user' , 'test' , 'database' );

    $result = $database->query("SELECT true;");

    $result->close();

    $database->close();

?>

Through trial and error I have found out that adding a $database->next_result(); solves the issue. But of course this can only be a workaround and not a solution to the actual problem.

Does anybody have an idea why this behavior occurs?

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用