w3resource

PHP mysqli: refresh() function

mysqli_refresh function / mysqli::refresh

The mysqli_refresh function / mysqli::refresh — refreshes

Syntax:

Object oriented style

public bool mysqli::refresh ( int $options )

Procedural style

int mysqli_refresh ( resource $link , int $options )

Parameter:

Name Description Required/Optional
link A link identifier returned by mysqli_connect() or mysqli_init() Required for procedural style only and Optional for Object oriented style
options The options to refresh, using the MYSQLI_REFRESH_* constants as documented within the MySQLi constants documentation. Required

Usage: Procedural style

mysqli_refresh(connection,options);

Parameter:

Name Description Required / Optional
connection Specifies the MySQL connection to use Required
options The options to refresh. Can be one of more of the following (separated by OR):
  • MYSQLI_REFRESH_GRANT - Refreshes the grant 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
Required

Return value:

TRUE if the refresh was a success, otherwise FALSE

Version: PHP 5, PHP 7

Example

<?php
$con=mysqli_connect("localhost","user1","datasoft123","hr");
if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

mysqli_refresh($con,MYSQLI_REFRESH_LOG);

mysqli_close($con);
?>

See also

PHP Function Reference

Previous: reap_async_query
Next: release_savepoint



PHP: Tips of the Day

var_export(): var_export() dumps a PHP parseable representation of the item.

You can pass true as the second parameter to return the contents into a variable.

Example:

<?php
$myarray = [ "PHP", "Tips" ];
$mystring = "PHP Tips";
$myint = 28;

var_export($myarray);
var_export($mystring);
var_export($myint);
?>

Output:

array (
  0 => 'PHP',
  1 => 'Tips',
)'PHP Tips'28

To put the content into a variable, you can do this:

$array_export = var_export($myarray, true);
$string_export = var_export($mystring, true);
$int_export = var_export($myint, 1); // any `Truthy` value

After that, you can output it like this:

printf('$myarray = %s; %s', $array_export, PHP_EOL);
printf('$mystring = %s; %s', $string_export, PHP_EOL);
printf('$myint = %s; %s', $int_export, PHP_EOL);

Example:

<?php
$myarray = [ "PHP", "Tips" ];
$mystring = "PHP Tips";
$myint = 28;
$array_export = var_export($myarray, true);
$string_export = var_export($mystring, true);
$int_export = var_export($myint, 1);
printf('$myarray = %s; %s', $array_export, PHP_EOL);
printf('$mystring = %s; %s', $string_export, PHP_EOL);
printf('$myint = %s; %s', $int_export, PHP_EOL);
?>

This will produce the following output:

Output:

$myarray = array (
  0 => 'PHP',
  1 => 'Tips',
);
$mystring = 'PHP Tips';
$myint = 28;