Bug #81367 [NEW]: bug ? PDO::bindValue data type inconsistent with expected results

From: Date: Tue, 17 Aug 2021 11:40:21 +0000
Subject: Bug #81367 [NEW]: bug ? PDO::bindValue data type inconsistent with expected results
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235896@lists.php.net to get a copy of this message
From: cevincheung at gmail dot com Operating system: Ubuntu 20.04.2 PHP version: 8.0.9 Package: PDO MySQL Bug Type: Bug Bug description:bug ? PDO::bindValue data type inconsistent with expected results Description: ------------ $db = new PDO(...); $stmt = $db->prepare("select :id col"); $stmt->bindValue(':id', '1' /* string */, PDO::PARAM_STR /* string */); $stmt->execute(); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); // got: string(1) "1" ok, right ~ but: $stmt->bindValue(':id', '1' /* string */, PDO::PARAM_INT /* int */); $stmt->execute(); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); // got: string(1) "1" why ? why ? What exactly is the third parameter of bindValue used for ? Wireshark report (for bindValue(':id', '1', PDO::PARAM_INT)): Parameter: Type: FILED_TYPE_VAR_STRING (253) Unsigned: 0 Value: 1 Test script: --------------- $db = new PDO(...); $stmt = $db->prepare("select :id col"); $stmt->bindValue(':id', '1' /* string */, PDO::PARAM_INT /* int */); $stmt->execute(); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); // got: string(1) "1" -- Edit bug report at https://bugs.php.net/bug.php?id=81367&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81367&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81367&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81367&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81367&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81367&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81367&r=support Expected behavior: https://bugs.php.net/fix.php?id=81367&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81367&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81367&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81367&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81367&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81367&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81367&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81367&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81367&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81367&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81367&r=mysqlcfg

« previous php.bugs (#235896) next »