سؤال

What's the point of using explicit data types in PDO::bindValue()?

For example in either of the following forms there would be an SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'a'

$pdos->bindValue(':Value_For_An_Int_Col', 'a');//default arg for the third and opt par is  PDO::PARAM_INT

$pdos->bindValue(':Value_For_An_Int_Col', 'a', PDO::PARAM_INT);
هل كانت مفيدة؟

المحلول

When you need something like

SELECT * FROM ... LIMIT :intValues

That avoids to enclose the value inside quote, rising a SQL syntax error

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top