[thelist] mysql_affected_rows();

Dunstan Orchard dunstan at 1976design.com
Fri Sep 27 06:24:01 CDT 2002


This is odd.

I'm running an update query on a mysql database.

// images query
$sql = ("UPDATE images SET title = '$title', date_shot = '$date_shot' WHERE
imageid = '$imageid'");

// run query
mysql_query($sql);

// count rows affected
$noar = mysql_affected_rows();

// do errors
if ($noar == '0')
	{
	$edit_images_update_error = "1";
	}
else
	{
	$edit_images_update_error = "0";
	}



If the data that's being updated has altered in any way then my number of
affected rows ($noar) returns true and my error = 0.

If the data hasn't changed, then $noar == 0, and my error = 1.


Does php/mysql compare my data then and decide that as it's the same it
doesn't need updating?

I don't get it?

Thanks - dunstan

---------------------------
Dorset, England
http://www.1976design.com/
http://www.orchard.it/
http://www.maccaws.org/



More information about the thelist mailing list