Home > Article > Backend Development > Detailed information about the number of affected rows
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
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?
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
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]:
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!