简体   繁体   English

在什么情况下PDO:execute()会返回false?

[英]Under what conditions will PDO:execute() return false?

According to http://php.net/manual/en/pdostatement.execute.php , it returns TRUE on success or FALSE on failure. 根据http://php.net/manual/en/pdostatement.execute.php ,如果成功,则返回TRUE;如果失败,则返回FALSE。

What constitutes success or failure? 什么是成功或失败?

I've tested it and returning an empty set or not inserting a row due to the WHERE clause does not. 我已经对其进行了测试,并且由于WHERE子句而没有返回空集或不插入行。

Will it only do so given invalid SQL? 鉴于无效的SQL,它只会这样做吗? If so, wouldn't this throw an exception as well? 如果是这样,这也不会引发异常吗?

It will return false on any query that could not be executed successfully. 对于任何无法成功执行的查询,它将返回false Reasons for this may include a disconnected database, query syntax errors, you trying to call undefined SQL functions and such. 造成这种情况的原因可能包括数据库断开连接,查询语法错误,您试图调用未定义的SQL函数等。 An empty result set is not a failure. 空结果集不是失败。

SQL错误,连接断开等...未启用抛出异常时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM