Bug #80445 [NEW]: Using float bind parameter returns weird error

From: Date: Mon, 30 Nov 2020 01:06:35 +0000
Subject: Bug #80445 [NEW]: Using float bind parameter returns weird error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230716@lists.php.net to get a copy of this message
From: domen at jollydeck dot com Operating system: Windows, CentOS PHP version: 7.4.13 Package: PDO MySQL Bug Type: Bug Bug description:Using float bind parameter returns weird error Description: ------------ Following code produces weird error "SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect INTEGER value" although no date or time is used anywhere. This only happens when PDO::ATTR_EMULATE_PREPARES is set to false and bound parameter is float. Table engine does not matter (tested with InnoDB and MyISAM). Statement executes successfully if bind parameter is integer or the value "0.3" is not bound but hard-coded into the query (either as '0.3' or as 0.3). Test script: --------------- <?php $pdo = new PDO('mysql:host=localhost;dbname=testdb', 'test_username', 'test_password'); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->query("CREATE TABLE test (field INT NOT NULL) ENGINE=InnoDB"); $pdo->query("INSERT INTO test (field) VALUES (0)"); $stmt = $pdo->prepare("UPDATE test SET field = 100 * ?"); $stmt->execute(array(0.3)); Expected result: ---------------- Query executes successfully Actual result: -------------- Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect INTEGER value: '0.3' in ... -- Edit bug report at https://bugs.php.net/bug.php?id=80445&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80445&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80445&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80445&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80445&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80445&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80445&r=support Expected behavior: https://bugs.php.net/fix.php?id=80445&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80445&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80445&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80445&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80445&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80445&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80445&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80445&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80445&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80445&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80445&r=mysqlcfg

« previous php.bugs (#230716) next »