Low cost ecommerce web development India flash website design

Counting Affected Rows


It’s also possible to find out how many rows were affected by an UPDATE, INSERT
or DELETE query, using the PHP function mysql_affected_rows. Use of
mysql_affected_rows is not common in typical PHP applications, but it could
be a good way to inform users that, “You’ve just deleted 1854 records from the
Customers table. Have a nice day!”
Unlike mysql_num_rows, which takes a result set resource identifier as its argument,
mysql_affected_rows takes the database connection identifier. It returns
the number of rows affected by the last query that modified the database, for the
specified connection.
Here’s how mysql_affected_rows can be used:
File: 16.php (excerpt)
// Connect to MySQL
$dbConn = &connectToDb($host, $dbUser, $dbPass, $dbName);
// A query which updates the database
$sql = "UPDATE
articles
SET
author='The Artist Formerly Known as...'
WHERE
author='HarryF'";
// Run the query, identifying the connection
$queryResource = mysql_query($sql, $dbConn);
// Fetch the number of rows affected
$changedRows = mysql_affected_rows($dbConn);
echo $changedRows . ' rows changed<br />';
As situations in which mysql_affected_rows is needed are uncommon, I’ll omit
this from the MySQLResult class in the interests of keeping things simple.

website designer freelance ASP PHP ecommerce web developer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110