mysql automatically cast strings to integer

前端 未结 3 1623
青春惊慌失措
青春惊慌失措 2021-01-13 05:52

I\'ve just noticed that if I do a MySQL request like this one:

SELECT 1 FROM myTable WHERE id = \'asdf\'

Then the string \'asdf\' is casted

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 06:19

    Since pdo prepared statements binding with correct types will not raise any error (except if mysql strict mode is enabled), your only choice is to ensure and control the types of your variables within your php to "correct" the permissivity of these languages.

    [thanks to commentators]

提交回复
热议问题