Gajus
Gajus

Reputation: 73848

is PDO::PARAM_INT redundant?

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?

Upvotes: 5

Views: 1932

Answers (1)

Matchu
Matchu

Reputation: 85802

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 likely is more concerned with other data types that should not be quoted or should be quoted differently, like PDO::PARAM_BOOL

Upvotes: 3

Related Questions