问题
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