|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-06-02 22:13 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2018-06-02 22:13 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 00:00:01 2025 UTC |
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