PHP mysql_info() 函數

定義和用法

mysql_info() 函數返回最近一條查詢的信息。

如果成功,則返回有關該語句的信息,如果失敗,則返回 false。

語法

mysql_info(connection)
參數 描述
connection 可选。規定 MySQL 連接。如果未規定,則使用上一個連接。

Description

mysql_info() returns the string through the given connection Details of the latest query performed. If not specified connectionIf not specified, it is assumed to be the last opened connection.

mysql_info() returns a string for all the following statements:

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

Returns false for any other statement. The format of the string depends on the given statement.

Example

<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db",$con);
$sql = "INSERT INTO person VALUES ('Bill','Gates','Utah','19')";
$result = mysql_query($sql,$con);
$info = mysql_info($con);
echo $info;
mysql_close($con);
?>

Output similar to:

String format: Records: 15 Duplicates: 0 Warnings: 0