|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-09-02 11:45 UTC] uw@php.net
-Status: Open
+Status: Bogus
[2011-09-02 11:45 UTC] uw@php.net
[2011-09-02 13:36 UTC] taopixdev at yahoo dot co dot uk
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 19:00:02 2025 UTC |
Description: ------------ I have tested this in different versions of PHP and it seems to be a bug from version 5.3.0 onwards. It seems that from PHP version 5.3.0 onwards that when a MySQL select statement returns zero rows the bind result variable is being overwritten and set to a null value. In the example attached to this post I initialize a variable called $recordID and set it to 0; In versions of PHP prior to version 5.3.0 after the fetch has ran the $recordID would still be set to 0 when zero rows are returned. However from versions 5.3.0 onwards the $recordID variable is overwritten and set to null. Test script: --------------- <?php $pID = 0; $recordID = 0; if ($stmt = $dbObj->prepare('SELECT `id`, `name` FROM MYTABLE WHERE id = ?) { if ($stmt->bind_param('i', $pID)) { if ($stmt->bind_result($recordID, $name) { if ($stmt->execute()) { $stmt->fetch(); } } } } ?> Expected result: ---------------- In versions of PHP prior to version 5.3.0 after the fetch has ran the $recordID would still be set to 0 when zero rows are returned. Actual result: -------------- From versions 5.3.0 onwards the $recordID variable is overwritten and set to null.