|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-07-02 06:00 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2020-07-02 06:00 UTC] requinix@php.net
[2020-07-02 06:41 UTC] morozov at tut dot by
[2020-07-02 06:55 UTC] requinix@php.net
[2020-07-02 07:21 UTC] nikic@php.net
[2020-07-02 15:11 UTC] morozov at tut dot by
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 06:00:01 2025 UTC |
Description: ------------ When interacting with a PDOStatement object, the consumer should be able to expect all exceptions to be reported as PDOException. However, in certain cases, the extension leaks its internal implementation details and throws an Error. Test script: --------------- <?php $conn = new PDO('sqlite:memory:'); $stmt = $conn->prepare('SELECT ?'); $stmt->bindValue(1, new DateTime()); try { $stmt->bindValue(1, new DateTime()); } catch (Throwable $e) { echo get_class($e), ': ', $e->getMessage(), PHP_EOL; } try { $stmt->execute([new DateTime()]); } catch (Throwable $e) { echo get_class($e), ': ', $e->getMessage(), PHP_EOL; } // the above seems to be implemented just by casting the value to a string since it behaves exactly as the following: try { (string) (new DateTime()); } catch (Throwable $e) { echo get_class($e), ': ', $e->getMessage(), PHP_EOL; } Expected result: ---------------- A PDOException is thrown instead of an Error PDOException: Some message that says that this type cannot be bound to the statement Actual result: -------------- Error: Object of class DateTime could not be converted to string