downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysqli_rpl_parse_enabled> <mysqli_param_count
[edit] Last updated: Fri, 25 May 2012

view this page in

mysqli_report

(PHP 5)

mysqli_report内部のレポート関数を有効あるいは無効にする

説明

bool mysqli_report ( int $flags )

mysqli_report() は、開発やテストのフェーズにおいて クエリの機能を向上させる強力な関数です。フラグの設定により、この関数は インデックスを使用しない(あるいは間違ったインデックスを使用している) mysqli 関数コールやクエリに対してエラーを報告します。

パラメータ

flags

使用できるフラグ
名前 説明
MYSQLI_REPORT_OFF レポート機能をオフにします。
MYSQLI_REPORT_ERROR mysqli 関数コールのエラーを報告します。
MYSQLI_REPORT_STRICT エラーが発生したときに、警告を発するのではなく mysqli_sql_exception をスローします。
MYSQLI_REPORT_INDEX クエリでインデックスを使用しない (あるいは 間違ったインデックスを使用している) 場合に報告します。
MYSQLI_REPORT_ALL すべてのオプションを設定します(report all)。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

変更履歴

バージョン 説明
5.2.15 & 5.3.4 レポートモードをリクエスト単位で変更できるようになりました。 これまではプロセス単位でしか変更できませんでした。

例1 オブジェクト指向型

<?php
/* レポート機能を有効にします */
mysqli_report(MYSQLI_REPORT_ALL);

$mysqli = new mysqli("localhost""my_user""my_password""world");

/* 接続状況をチェックします */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

/* このクエリはエラーを報告します */
$result $mysqli->query("SELECT Name FROM Nonexistingtable WHERE population > 50000");

/* このクエリは警告を発生させます */
$result $mysqli->query("SELECT Name FROM City WHERE population > 50000");
$result->close();

$mysqli->close();
?>

参考



mysqli_rpl_parse_enabled> <mysqli_param_count
[edit] Last updated: Fri, 25 May 2012
 
add a note add a note User Contributed Notes mysqli_report
grepmaster 22-Mar-2009 06:51
Hint: If you use

mysqli_report(MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_STRICT)

normal errors are generated instead of exceptions.
Polarina 10-Nov-2007 04:08
It should be noted that all reports made by this function, are sent through an exception named 'mysqli_sql_exception' instead of a normal PHP warning.
anthony dot parsons at manx dot net 05-Nov-2005 08:23
Be very careful using this function - it's a per-process setting.
If your server is set up to reuse a single PHP process for multiple requests, that means the last setting of this function in any script will affect all other scripts using mysqli.
To be safe always call <? mysqli_report(MYSQLI_REPORT_OFF) ?> at the end of a script. The CGI version of PHP is probably safe from this.

(Tested using PHP 5.0.5, Apache 2 SAPI module)

 
show source | credits | sitemap | contact | advertising | mirror sites