Bug #76408 [NEW]: no result if field in where clause of SQL-statement is float

From: Date: Sat, 02 Jun 2018 22:10:41 +0000
Subject: Bug #76408 [NEW]: no result if field in where clause of SQL-statement is float
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215477@lists.php.net to get a copy of this message
From: michael dot gautschi at gmail dot com Operating system: Windows PHP version: 7.2.6 Package: PDO related Bug Type: Bug Bug description:no result if field in where clause of SQL-statement is float Description: ------------ If the type of the field is "float" a query with a parameter will not return any result and if the same field has the type "decimal" a result is returned. Test script: --------------- Let's create two tables: CREATE TABLE weightd ( idweight int(11) NOT NULL, weightkg decimal(10,2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO weightd (idweight, weightkg) VALUES (1, '77.90'); CREATE TABLE weightf ( idweight int(11) NOT NULL, weightkg float(10,2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO weightf (idweight, weightkg) VALUES (1, '77.90'); ------ The script: <?php $db = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); $s = $db->prepare('select * from weightd where weightkg = :p0'); $s->execute(array(':p0' => '77.9')); $r = $s->fetchAll(); var_dump($r); $db = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); $s = $db->prepare('select * from weightf where weightkg = :p0'); $s->execute(array(':p0' => '77.9')); $r = $s->fetchAll(); var_dump($r); Expected result: ---------------- Two times the following output: array (size=1) 0 => array (size=4) 'idweight' => string '1' (length=1) 0 => string '1' (length=1) 'weightkg' => string '77.90' (length=5) 1 => string '77.90' (length=5) Actual result: -------------- array (size=1) 0 => array (size=4) 'idweight' => string '1' (length=1) 0 => string '1' (length=1) 'weightkg' => string '77.90' (length=5) 1 => string '77.90' (length=5) array (size=0) empty -- Edit bug report at https://bugs.php.net/bug.php?id=76408&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76408&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76408&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76408&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76408&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76408&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76408&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76408&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76408&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76408&r=support Expected behavior: https://bugs.php.net/fix.php?id=76408&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76408&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76408&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76408&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76408&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76408&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76408&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76408&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76408&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76408&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76408&r=mysqlcfg

« previous php.bugs (#215477) next »