Do I need to use (int)$id before I use $id in bindValue in Php PDO

[亡魂溺海] 提交于 2019-12-01 13:54:39

No it's not required for two reasons:

  1. You're letting PDO know that you are going to query the database for a column ID. PDO isn't going to parse anything in $_POST['id'].

  2. The second value of bindValue is automatically casted to a string (or of any type you might want to select). Here int $data_type = PDO::PARAM_STR

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!