PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




mysql_info function in PHP


Tutorials »Php »

Topic

What is mysql_info() function in PHP?
How does mysql_info() works?




Explanation

The mysql_info() function returns information about the last query.

Syntax

string mysql_info ( [resource link_identifier])

Returns information about the last executed query statement on success, or FALSE on failure.

mysql_info() returns detailed information about the last executed query using the given link_identifier. If link_identifier is not specified, the last connection opened by mysql_connect() or mysql_pconnect() link is assumed.

There are five different types of query that mysql_info() will return information about:


Statement: INSERT [INTO] (tablename) [(fieldnames)] VALUES (values)
Returned String: Records: x Duplicates: y Warnings: z

Statement: INSERT INTO (tablename) [(fieldnames)] SELECT (statement)
Returned String: Records: x Duplicates: y Warnings: z

Statement: LOAD DATA INFILE (filename) INTO TABLE (tablename)
Returned String: Records: w Deleted: x Skipped: y Warnings: z

Statement: ALTER TABLE
Returned String: Records: 60 Duplicates: 0 Warnings: 0

Statement: UPDATE (condition) (new value)
Returned String: Rows matched: x Changed: y Warnings: z


Example


<?php

//Attempt to connect to the default database server
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");

//select database
mysql_select_db('database');

$query = "UPDATE People SET Title = 'Mr' WHERE FirstName='Bill'";

//execute query
$result = mysql_query($query);

//print mysql_info function result
printf("Query Information: %s\n", mysql_info()");
?>


In the above code, update query is executed to change the record based on the query condition. After the successful execution of update query mysql_info() function will return string containing query information.

RESULT:

Query Information : Rows matched: 1 Changed: 1 Warnings: 0

Above Query Information represent one row matched and one row changed based on query condition and zero warnings.

See also: mysql_affected_rows().





Other Links

web hosting