PDOStatement::fetch() 方法抛出 PDOException 的可能性
Possibility for PDOStatement::fetch() method to throw a PDOException
PDOStatement::fetch()
是否可能抛出异常 (PDOException) 或只有 $dbh->prepare($query)->execute()
会抛出错误?
如果 PDOStatement::fetch()
不会抛出错误,那么我可以放心地使用它而无需将其放在 try...catch
子句中
@WeeZel 为这个问题提供了很好的答案:PDOStatement::fetch() doesn't have an Errors/Exceptions section in the documentation so it won't throw one (see PDO::__construct 作为抛出错误时预期结果的示例。
请参考以上评论
PDOStatement::fetch()
是否可能抛出异常 (PDOException) 或只有 $dbh->prepare($query)->execute()
会抛出错误?
如果 PDOStatement::fetch()
不会抛出错误,那么我可以放心地使用它而无需将其放在 try...catch
子句中
@WeeZel 为这个问题提供了很好的答案:PDOStatement::fetch() doesn't have an Errors/Exceptions section in the documentation so it won't throw one (see PDO::__construct 作为抛出错误时预期结果的示例。
请参考以上评论