LoginSignup
0
0

More than 1 year has passed since last update.

mysqlのPDOで接続するとstring型になってしまう理由と対策

Last updated at Posted at 2022-01-27

参考サイト

デフォルトモードのPDOでMySQLに接続している場合、int型でも(他の型でも)string型で返ってくるという挙動があり、これは仕様のようです。

解決法1

フェッチした後にキャストすることで対処はできる。

 解決法2

PDO::ATTR_EMULATE_PREPARES属性をfalseにすることで型変換を回避する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0