SQLite3::enableExceptions() - sqlite3数据库类
SQLite3::enableExceptions()
(PHP 5 >= 5.3.0, PHP 7)
Enable throwing exceptions
说明
SQLite3::enableExceptions([bool $enableExceptions=FALSE
]): boolControls whether the SQLite3 instance will throw exceptions or warnings on error.
参数
$enable When TRUE
, the SQLite3 instance, and SQLite3Stmt and SQLite3Result instances derived from it, will throw exceptions on error.
When FALSE
, the SQLite3 instance, and SQLite3Stmt and SQLite3Result instances derived from it, will raise warnings on error.
For either mode, the error code and message, if any, will be available via SQLite3::lastErrorCode() and SQLite3::lastErrorMsg() respectively.
返回值
Returns the old value;TRUE
if exceptions were enabled,FALSE
otherwise.
范例
SQLite3::enableExceptions() example
以上例程的输出类似于:
Warning: SQLite3::exec(): near "foo": syntax error in example.php on line 4 Caught exception: near "bar": syntax error
Be sure to note the poorly chosen name and default value. The following snippet does not throw an exception, despite calling a function with the name "enableExceptions" immediately prior to the bad query. Note that this is still error-prone if the passed value is false. One is likely to read "enableExceptions" and ignore the parameter list since the function name conveys a strong (but incorrect) meaning.
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!