mysqli_report
(PHP 5)
mysqli_report — Enables or disables internal report functions
Описание
bool mysqli_report
( int $flags
)
mysqli_report() is a powerful function to improve your queries and code during development and testing phase. Depending on the flags it reports errors from mysqli function calls or queries which don't use an index (or use a bad index).
Список параметров
- flags
-
Supported flags Name Description MYSQLI_REPORT_OFF Turns reporting off MYSQLI_REPORT_ERROR Report errors from mysqli function calls MYSQLI_REPORT_STRICT Report warnings from mysqli function calls MYSQLI_REPORT_INDEX Report if no index or bad index was used in a query MYSQLI_REPORT_ALL Set all options (report all)
Возвращаемые значения
Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.
Примеры
Пример #1 Object oriented style
<?php
/* activate reporting */
mysqli_report(MYSQLI_REPORT_ALL);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* this query should report an error */
$result = $mysqli->query("SELECT Name FROM Nonexistingtable WHERE population > 50000");
/* this query should report a warning */
$result = $mysqli->query("SELECT Name FROM City WHERE population > 50000");
$result->close();
$mysqli->close();
?>
Смотрите также
- mysqli_debug()
- mysqli_dump_debug_info()
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MySQL Drivers and Plugins
- Улучшенный модуль MySQL
- mysqli_bind_param
- mysqli_bind_result
- mysqli_client_encoding
- mysqli_connect
- mysqli::disable_reads_from_master
- mysqli_disable_rpl_parse
- mysqli_enable_reads_from_master
- mysqli_enable_rpl_parse
- mysqli_escape_string
- mysqli_execute
- mysqli_fetch
- mysqli_get_cache_stats
- mysqli_get_links_stats
- mysqli_get_metadata
- mysqli_master_query
- mysqli_param_count
- mysqli_report
- mysqli_rpl_parse_enabled
- mysqli_rpl_probe
- mysqli_send_long_data
- mysqli::set_opt
- mysqli_slave_query
Коментарии
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.
Hint: If you use
mysqli_report(MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_STRICT)
normal errors are generated instead of exceptions.
If you use your own DBException handling for example
<?php
if (!@real_connect(HOST, USERNAME, PASSWORD, NAME, PORT))
{
throw new DBException(connect_errno);
}
?>
Then turn off errors like this for php 8 >
<?php
mysqli_report(MYSQLI_REPORT_OFF);
?>