Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?

More than 3 years have passed since last update.

@black_iron

mysqliでクエリエラーを出力するようにする

ログを見に行くのが面倒で画面に出力して欲しくなったので。

やり方

mysqli_reportを使う。

mysqli_report(MYSQLI_REPORT_ERROR);

// テーブル名をtypoしている。正しくはinformation
$mysqli->query('select * from infomation where info_id = 1');

これを実行すると下記の警告を出力してくれる。

Warning: mysqli::query(): (42S02/1146): Table 'test.infomation' doesn't exist in /Applications/MAMP/htdocs/index.php on line 11

蛇足

MYSQLI_REPORT_INDEXを追加するとインデックス未使用時に警告が出るようになります。

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_INDEX);
1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
1
Help us understand the problem. What is going on with this article?