当PDO告诉我们不要这样做时,为什么会生成警告? [英] Why PDO generates warnings when we tell it not to do it?

查看:112
本文介绍了当PDO告诉我们不要这样做时,为什么会生成警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

我们告诉PDO将每个问题包装成异常. 在某些情况下,它会生成一些警告,然后才引发异常.

We tell PDO to wrap each issue into exception. In some cases it generates a few warnings and only then throws exception.

为什么这样做?

重复吗?

对此,尚无正确答案.最后一个问题是 PHP PDO异常+ MySQL警告已消失?,但是人们只是将其标记为重复,而不是仔细回答.

There were no correct answers on SO regarding it. Last question was PHP PDO Exception + Warning on MySQL Has Gone Away? but people just marked it as duplicate instead of carefully answer.

接受的答案不能回答为什么这样做以及何时这样做.因此,我进行了研究并将回答.

Accepted answer not answers why does it do it and when. So I researched and will answer.

推荐答案

这是因为PDO可以使用mysqlnd驱动程序,因此不遵循PDO的任何将问题转换为扩展"政策.

It's because of PDO could use mysqlnd driver, which not respects any of PDO's "convert-issues-to-extensions" policy.

只需查看我们清楚地看到有直接呼叫php_error_docref.

We clearly see there direct calls to php_error_docref.

其中一个示例,显示在上一个问题由以下几行解释:

And one of examples, shown at previous question explained by these lines: https://github.com/php/php-src/blob/PHP-5.5.31/ext/mysqlnd/mysqlnd_wireprotocol.c#L35:L61

这篇关于当PDO告诉我们不要这样做时,为什么会生成警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆