Bug #76665 [Opn]: SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle
| From: | ab@php.net | Date: | Thu, 26 Jul 2018 09:53:47 +0000 |
| Subject: | Bug #76665 [Opn]: SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't juggle | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216474@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76665&edit=1
ID: 76665
Updated by: ab@php.net
Reported by: cmb@php.net
Summary: SQLite3Stmt::bindValue() with SQLITE3_FLOAT doesn't
juggle
Status: Open
Type: Bug
Package: SQLite related
Operating System: *
PHP Version: 7.2.8
Block user comment: N
Private report: N
New Comment:
You got it, Christoph. Looks like just uncommenting it and adding test should be fine for 7.1.
thanks.
Previous Comments:
------------------------------------------------------------------------
[2018-07-25 17:25:00] cmb@php.net
Description:
------------
If SQLite3Stmt::bindValue() is called with the explicit $type
SQLITE3_FLOAT, and a $value which is not a float, garbage is
written to the database in the best case.
For some reason the respective conversion to double[1] is
commented out since ext/sqlite3 has been moved to php-src (and
actually has been commented out at least since PECL/sqlite3
version 0.3).
[1] <https://github.com/php/php-src/blob/php-7.2.8/ext/sqlite3/sqlite3.c#L1598>
Test script:
---------------
<?php
$db = new SQLite3('memory');
$db->exec("CREATE TABLE foo (bar REAL)");
$stmt = $db->prepare("INSERT INTO foo VALUES (:bar)");
$stmt->bindValue(':bar', 17, SQLITE3_FLOAT);
$stmt->execute();
var_dump($db->querySingle("SELECT bar FROM foo LIMIT 1"));
Expected result:
----------------
float(17)
Actual result:
--------------
float(8.3991159793012E-323)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76665&edit=1