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

From: Date: Sat, 02 Jun 2018 22:13:29 +0000
Subject: Bug #76408 [Opn->Nab]: no result if field in where clause of SQL-statement is float
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215478@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76408&edit=1 ID: 76408 Updated by: requinix@php.net Reported by: michael dot gautschi at gmail dot com Summary: no result if field in where clause of SQL-statement is float -Status: Open +Status: Not a bug Type: Bug Package: PDO related Operating System: Windows PHP Version: 7.2.6 Block user comment: N Private report: N New Comment: https://dev.mysql.com/doc/refman/8.0/en/problems-with-float.html Previous Comments: ------------------------------------------------------------------------ [2018-06-02 22:10:39] michael dot gautschi at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=76408&edit=1

« previous php.bugs (#215478) next »