Home  >  Article  >  Backend Development  >  Detailed information about the number of affected rows

Detailed information about the number of affected rows

巴扎黑
巴扎黑Original
2017-06-10 16:26:463456browse

How to get the number of affected rows added, deleted or modified through SQL aggregate function? It is often very useful to be able to calculate the number of rows returned or affected by a query before taking further action. This function is particularly convenient when you want to display results in pages or generate statistical information. So how is the function of getting the number of affected rows implemented? Woolen cloth? 1. Use the SQL aggregation function COUNT to count the number of result records. COUNT returns the number of rows of a query or part of a query. It is usually used together with DINSTINCT. SQL's aggregate function COUNT is widely supported by a variety of databases! 2. Return the number of affected rows through the PDOStatement->rowCount() method. The PDOStatement->rowCount() method obtains the number of rows affected by UPDATE, INSERT or DELECTE queries. The rowCount() method is not common in typical PHP applications, but it can count how many rows were affected after calling PDOStatement->execute. 3. Application example using SQL aggregate function CO

1. How to obtain the number of affected rows that have been added, deleted or modified through SQL aggregate function?

Detailed information about the number of affected rows

Introduction: It is usually possible to calculate the number of rows returned or affected by a query before taking further action. All are very useful. This function is particularly convenient when you want to display results in pages or generate statistical information. So how is the function of getting the number of affected rows implemented?

2. Detailed introduction to the method of using PDO exec() function to query the number of affected rows after execution

Detailed information about the number of affected rows

Introduction: This article mainly introduces how PHP uses the exec() function under PDO to query the number of affected rows after execution. It analyzes the use of PHP in the form of examples. When pdo performs addition, deletion and modification operations, the exec() function queries the number of affected rows after the operation is executed. Friends who need it can refer to the following

3. PDO Execute SQL statements in

Detailed information about the number of affected rows

Introduction: exec() method The exec() method returns the affected rows after execution Number, the syntax is as follows: int PDO::exec(string statement) parameter statement is the SQL statement to be executed. This method returns the number of rows affected when executing the query and is typically used in INSERT, DELETE and UPDATE statements. For example: $dbms='mysql';//Database type $dbName='admin';//Database used $us

4. sql returns the result after adding data Affected row data

#Introduction: The Inserted table is used to store copies of rows affected by INSERT and UPDATE statements. In an insert or update transaction, new rows are added to both the inserted table and the trigger table

[Related Q&A recommendations]:

php gets mysql update results

When php uses sp_executesql to perform an insert operation, it successfully returns -1 and does not return the number of affected rows. How can I return the number of affected rows?

The above is the detailed content of Detailed information about the number of affected rows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn