mysqli_warning::next
Fetch next warning
The mysqli_warning::next() function is used to get the next warning message.
usage:
bool mysqli_warning::next ( void )
This function has no parameters.
Return value:
Example:
<?php // 创建一个数据库连接$mysqli = new mysqli("localhost", "username", "password", "database"); // 检查连接是否成功if ($mysqli->connect_errno) { echo "连接数据库失败:" . $mysqli->connect_error; exit(); } // 执行一个可能会产生警告的查询$query = "SELECT * FROM my_table"; $result = $mysqli->query($query); // 检查是否有警告信息if ($mysqli->warning_count > 0) { // 获取第一个警告信息$warning = $mysqli->get_warnings(); // 循环获取所有警告信息while ($warning != null) { echo "警告: " . $warning->message . "<br>"; // 获取下一个警告信息$warning->next(); } } // 关闭数据库连接$mysqli->close(); ?>
In the example above, we first create a database connection and execute a query that may generate warnings. We then check if there is a warning message available. If so, we use the mysqli::get_warnings() function to get the first warning information and use the mysqli_warning::next() function to loop over the remaining warning information. Finally, we close the database connection.
Please note that before using the mysqli_warning::next() function, we first need to use the mysqli::get_warnings() function to get the first warning message.