Home  >  Article  >  Backend Development  >  Which PHP function is used to get the number of rows affected by a MySQL query?

Which PHP function is used to get the number of rows affected by a MySQL query?

WBOY
WBOYforward
2023-08-25 23:13:111467browse

Which PHP function is used to get the number of rows affected by a MySQL query?

PHP uses the mysql_affected_rows( ) function to find out how many rows were changed by the query. This function basically returns the number of rows affected in a previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query. Returns an integer > 0 indicating the number of rows affected, 0 indicating that no records were affected, and -1 indicating that the query returned an error. Its syntax is as follows -

Syntax

mysql_affected_rows( connection );

The following are the parameters used in the function -

##1.
S. No.

Parameters and description

ConnectionRequired – Specifies the MySQL connection to use

The above is the detailed content of Which PHP function is used to get the number of rows affected by a MySQL query?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete