PHP 7.1 & 中的 PDO::PARAM_INT 行为PHP 7.2 [英] PDO::PARAM_INT behaviour in PHP 7.1 & PHP 7.2

查看:53
本文介绍了PHP 7.1 & 中的 PDO::PARAM_INT 行为PHP 7.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当传递带有 PDO::PARAM_INT 的字符串时,PHP 7.2 中的行为似乎发生了变化.在 7.1 版本中,更新的值和传递的字符串是相同的,在 PHP 7.2 中,更新的值是3"(见下面的例子).

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).

当然,我知道使用 PDO::PARAM_INT 传递字符串是错误的,但我想知道为什么在 PHP 更改日志中找不到任何内容以及为什么没有抛出异常或警告.

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();

推荐答案

这是修复 https://bugs.php.net/bug.php?id=73234

https://github.com/php/php-src/commit/32b6154a6385c7f97fc5d27/a>

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

这篇关于PHP 7.1 & 中的 PDO::PARAM_INT 行为PHP 7.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆