|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-07 12:39 UTC] uw@php.net
[2008-01-07 17:24 UTC] uw@php.net
[2011-01-01 23:53 UTC] jani@php.net
-Package: Feature/Change Request
+Package: PDO related
[2011-08-22 14:00 UTC] rosen at developer dot bg
[2011-08-22 14:03 UTC] rosen at developer dot bg
[2017-04-24 19:09 UTC] adambaratz@php.net
-Package: PDO related
+Package: PDO MySQL
[2020-12-08 09:10 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2020-12-08 09:10 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
Description: ------------ If using the MySQL PDO driver in PDO::ERRMODE_EXCEPTION mode, calling fetch() after executing an INSERT/UPDATE/DELETE statement throws an exception. Instead, it should return FALSE in this case like for an empty result set. Please compare to the SQLite PDO driver which works correctly. Reproduce code: --------------- <?php $db = new PDO( $dsn, $username, $password ); $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); try { $db->exec("CREATE TABLE IF NOT EXISTS TestTable (id INT)"); $sql = 'INSERT INTO TestTable VALUES ( NULL )'; $query = $db->prepare( $sql ); $query->execute(); while( ( $row = $query->fetch( PDO::FETCH_ASSOC ) ) !== FALSE ) {} $query->closeCursor(); } catch( PDOException $pe ) { echo 'Got PDOException: ' . $pe->getMessage(); } ?> Expected result: ---------------- $query->fetch() should return FALSE, as it is not an error to call fetch() for an INSERT statement, because it might be unknown what type of statement will be executed (like in an SQL shell where users can enter their custom queries). Actual result: -------------- PDOException