LoginSignup
3
3

More than 5 years have passed since last update.

PDOで明らかなエラー時に例外を投げてくれない時

Last updated at Posted at 2013-11-17

明らかな構文ミスでもPDOExceptionを投げてくれない場合

PDOのエラーモードを、例外を投げてくれるように予め設定しておく

<?php

$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

※具体的なモード内容

※そもそもMySQL側で変換されてる場合はエラーにもならないのでその点も注意

3
3
2

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
3
3