PHP mysqli_info() Function
In this chapter you will learn:
- Definition for PHP mysqli_info() Function
- Syntax for PHP mysqli_info() Function
- Parameter for PHP mysqli_info() Function
- Return for PHP mysqli_info() Function
- Example - finds out the information about the most recently executed query
- Example - Object oriented style
Definition
The mysqli_info() function returns information about the most recently executed query.
Syntax
PHP mysqli_info() Function has the following syntax.
mysqli_info(connection);
Parameter
Parameter | Is Required | Description |
---|---|---|
connection | Required. | Specifies the MySQL connection to use |
Return
A character string representing additional information about the most recently executed query.
Example 1
The following code finds out the information about the most recently executed query.
It returns a string containing information about the most recently executed query.
<?php/* ja v a 2 s .co m*/
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql1="CREATE TABLE NewTable LIKE emp";
mysqli_query($con,$sql1);
echo mysqli_info($con);
mysqli_close($con);
?>
Example 2
<?php/*from j av a2 s . co m*/
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("CREATE TEMPORARY TABLE t1 LIKE emp");
/* INSERT INTO .. SELECT */
$mysqli->query("INSERT INTO t1 SELECT * FROM emp");
print $mysqli->info;
$mysqli->close();
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_init() Function
- Syntax for PHP mysqli_init() Function
- Example - create an object for mysqli_real_connect() function
Home » PHP Tutorial » PHP MySQLi Functions