How Do You Find The Error, How Can You Know The Number Of Rows Affected By Last Sql Statement?
Answers
Answered by
0
Answer :-
By using the function rowCount()
Explanation :-
It returns the number of rows affected by the last SQL statement such as DELETE, INSERT, or UPDATE statement
Syntax :- rowCount (void)
Example 1 :- Return the number of deleted rows
<?php
/* Delete all rows from the FRUIT table */
$del = $dbh->prepare('DELETE FROM fruit');
$del->execute();
/* Return number of rows that were deleted */
print("Return number of rows that were deleted:\n");
$count = $del->rowCount();
print("Deleted $count rows.\n");
?>
The above example will output:
Return number of rows that were deleted:
Deleted 9 rows
Similar questions