PDO::PARAM_INT behaviour in PHP 7.1 & PHP 7.2

余生颓废 提交于 2021-02-07 08:20:39

问题


When passing a string with PDO::PARAM_INT there seems to be a change of behaviour in PHP 7.2. In Version 7.1 the updated value and the passed string were identical, in PHP 7.2 the updated value is "3" (see example below).

Of course I'm aware that passing a string using PDO::PARAM_INT is wrong, but I'm wondering why there is nothing to be found in the PHP changelog and why there is no exception or warning thrown.

Does anyone know if this is a desired behaviour?

$sql = "UPDATE test SET name = :name WHERE id = 1";

$update = $db->prepare($sql);   
$update->bindValue(':name', '3hgsf5-458752shUGVZCF', PDO::PARAM_INT);

$update->execute();

回答1:


It is a side-effect of fixing https://bugs.php.net/bug.php?id=73234

https://github.com/php/php-src/commit/32b6154a61fae820386527f3019f8c5937fc5d27



来源:https://stackoverflow.com/questions/54413798/pdoparam-int-behaviour-in-php-7-1-php-7-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!