PHP mysqli_refresh() Function

PHP mysqli_refresh() function is used to refreshes tables or caches, or resets the replication server information.

Syntax

int mysqli_refresh(connection, options);

mysqli_refresh() Function Parameter

ParameterDescription
connection :Required parameter. The MySQL connection to be used
options :Required parameter. The options to refresh. Can be one the following:

  • MYSQLI_REFRESH_GRANT - Refreshes the tables
  • MYSQLI_REFRESH_LOG - Flushes the logs
  • MYSQLI_REFRESH_TABLES - Flushes the table cache
  • MYSQLI_REFRESH_HOSTS - Flushes the host cache
  • MYSQLI_REFRESH_STATUS - Resets the status variables
  • MYSQLI_REFRESH_THREADS - Flushes the thread cache
  • MYSQLI_REFRESH_SLAVE - Resets the master server info, and restarts the slave
  • MYSQLI_REFRESH_MASTER - Removes the binary log files in the binary log index, and truncates the index file

mysqli_refresh() Function Return Value

Return Values :Returns TRUE if the refresh was a success, otherwise FALSE

mysqli_refresh() Function Example

<?php
$con = mysqli_connect("localhost","user","password","db");

if (mysqli_connect_errno())
{
	echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_refresh($con, MYSQLI_REFRESH_LOG);

mysqli_close($con);
?>