|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-12-17 16:30 UTC] bill at zeroedin dot com
Description:
------------
I am documenting the previously undocumented method SQLite3::enableExceptions, and I notice that the method has some weird behavior.
Currently, if you call enableExceptions(true) and exceptions were previously disabled, it returns false. The inverse is also true.
If you call enableExceptions(), it turns off exceptions for the driver and returns whatever value was previously set.
The behavior should be changed to match other similar methods on other drivers.
The method should only change the exception behavior if the $enableExceptions parameter is true or false passed by the user. If no value is passed, the method should return the current state of the flag and take no action. When $enableExceptions is passed by the user, the method should set the value and then return the new value.
Test script:
---------------
$sqlite3 = new SQLite3(':memory:');
var_dump($sqlite3->enableExceptions(true));
var_dump($sqlite3->enableExceptions());
var_dump($sqlite3->enableExceptions());
var_dump($sqlite3->enableExceptions(false));
var_dump($sqlite3->enableExceptions());
var_dump($sqlite3->enableExceptions());
Expected result:
----------------
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
Actual result:
--------------
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 06:00:01 2025 UTC |
After further consideration I don't think that changing the behavior of SQLite3::enableException() is viable (at least not without an explicit RFC) due to BC concerns. Furthermore, getting the current state seems to be rarely needed, and if one needs it, one could still write a function in userland: <?php function exceptions_enabled() { $current = SQLite3::enableException(); SQLite3::enableException($current); return $current; }