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

From: Date: Tue, 17 Aug 2021 11:49:24 +0000
Subject: Bug #81367 [Opn]: bug ? PDO::bindValue data type inconsistent with expected results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235897@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81367&edit=1 ID: 81367 User updated by: cevincheung at gmail dot com Reported by: cevincheung at gmail dot com Summary: bug ? PDO::bindValue data type inconsistent with expected results Status: Open Type: Bug Package: PDO MySQL Operating System: Ubuntu 20.04.2 PHP Version: 8.0.9 Block user comment: N Private report: N New Comment: bindValue(':id', int, PDO::PARAM_INT) got: int(1) Previous Comments: ------------------------------------------------------------------------ [2021-08-17 11:40:21] cevincheung at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=81367&edit=1

« previous php.bugs (#235897) next »