I have this query :
INSERT INTO db1.outbox (DestinationNumber, TextDecoded)
SELECT User.CellPhone, \'$SMSMessage\' as TextDecoded
FROM db2.User
WHERE User.Pu
Here are some possibilities:
» If you have an AUTO_INCREMENT
column, you can fetch the row number before and after insert
» SELECT ROW_COUNT()
returns the number of rows changed, deleted, or inserted by the last statement if it was an UPDATE
, DELETE
, or INSERT
(doc)
» You can use mysqli_affected_rows
(since mysql_
functions are being deprecated) to get the number of affected rows in a previous MySQL operation (doc)
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
/* Insert rows */
mysqli_query($link, "INSERT INTO myTable VALUES (1)");
printf("Affected rows (INSERT): %d\n", mysqli_affected_rows($link));
put this on your last statement;
SELECT ROW_COUNT();
UPDATE 1
how about using mysql_affected_rows, example
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
/* this should return the correct numbers of deleted records */
mysql_query('you SQL QUERY HERE');
printf("Records deleted: %d\n", mysql_affected_rows());
?>