是PDO :: PARAM_INT冗余吗? [英] is PDO::PARAM_INT redundant?
问题描述
PDO::PARAM_INT
与$db->quote()
函数一起使用时是否完全执行任何功能?例如$db->quote($user['id'], PDO::PARAM_INT)
?
Does PDO::PARAM_INT
perform any function at all when used with $db->quote()
function? e.g. $db->quote($user['id'], PDO::PARAM_INT)
?
似乎是这样,因为即使是字符串输入也将通过低谷.更不用说它使引号保持在整数附近.我有什么理由要使用它吗?
It seems like it is, because even string input will get passed trough. Not to mention that it keeps the quotes around the integer. Is there any reason why should I use it?
推荐答案
它没有任何作用,因为毕竟您正在运行quote
函数.用引号将它包裹起来是很自然的. PDO::PARAM_INT
在其他情况下(例如,准备好的语句)在实际上与字符串的处理方式不同的情况下可能更重要.
It has no effect, since, after all, you are running the quote
function. It's only natural that it gets wrapped in quotes. PDO::PARAM_INT
is likely more important in other contexts, like prepared statements, where it is actually handled differently than strings.
quote
可能更关心其他不应被引用或应被不同引用的数据类型,例如PDO::PARAM_BOOL
quote
likely is more concerned with other data types that should not be quoted or should be quoted differently, like PDO::PARAM_BOOL
这篇关于是PDO :: PARAM_INT冗余吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!