📜  \PDO::ATTR_EMULATE_PREPARES => true 安全问题 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:03.904000             🧑  作者: Mango

代码示例1
The option

'options'   => [
                \PDO::ATTR_EMULATE_PREPARES => true
            ]
will resolve the issue, However, beside the security issues it generates, it also effect all select queries that you perform on the DB in the way that it force/convert every returned type from the DB to be string instead of the real type (integer/ float)

How does it effect you?

if you have a validation layer above the result of the query, you can't perform something like (

if (is_int($model->id))
) which will return 0 always, because it's string not an integer anymore.