Horje Website
PHP mysqli affected_rows Function – Example – Object Oriented style

PHP mysqli affected_rows Function – Example – Object Oriented style

Return the number of affected rows from different queries:

 
 
  1. <?php
  2. $mysqli = new mysqli("localhost","my_user","my_password","my_db");
  3. if ($mysqli -> connect_errno) {
  4. echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  5. exit();
  6. }
  7. // Perform queries and print out affected rows
  8. $mysqli -> query("SELECT * FROM Persons");
  9. echo "Affected rows: " . $mysqli -> affected_rows;
  10. $mysqli -> query("DELETE FROM Persons WHERE Age>32");
  11. echo "Affected rows: " . $mysqli -> affected_rows;
  12. $mysqli -> close();
  13. ?>

 

Published:
November 15, 2022
Author:
admin
Category:
Mysql, PHP Source Code
Views:
12

This article was posted in Mysql, PHP Source Code. Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2022