PHP mysqli info() Function

❮ PHP MySQLi Reference

Example - Object Oriented style

Return information about the last executed query:

<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");

if ($mysqli -> connect_errno) {
  echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  exit();
}

// Perform some queries
$mysqli -> query("CREATE TABLE testPersons LIKE Persons");
$mysqli -> query("INSERT INTO testPersons SELECT * FROM Persons ORDER BY LastName");

echo $mysqli -> info;

$mysqli -> close();
?>

Look at example of procedural style at the bottom.


Definition and Usage

The info / mysqli_info() function returns information about the last executed query.

This function works with the following query types:

  • INSERT INTO...SELECT...
  • INSERT INTO...VALUES (...),(...),(...)
  • LOAD DATA INFILE ...
  • ALTER TABLE ...
  • UPDATE ...

Syntax

Object oriented style:

$mysqli -> info

Procedural style:

mysqli_info(connection)

Parameter Values

Parameter Description
connection Required. Specifies the MySQL connection to use

Technical Details

Return Value: A string that contains additional info about the last executed query
PHP Version: 5+

Example - Procedural style

Return information about the last executed query:

<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  exit();
}

// Perform som queries
mysqli_query($con, "CREATE TABLE testPersons LIKE Persons");
mysqli_query($con, "INSERT INTO testPersons SELECT * FROM Persons ORDER BY LastName");

echo mysqli_info($con);

mysqli_close($con);
?>


❮ PHP MySQLi Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.