How to do it in one query?
You can do something like:
function updateValue()
{
mysql_query($sql); // your update goes here
return mysql_affected_rows() > 0;
}
From BoltClock's comment:
Bear in mind that mysql_affected_rows() returns 0 if a row exists but the old and new values are equal (meaning there was no need for an update).
You may use mysql_affected_rows() function to check, whether any rows were affected by update. See for details: http://php.net/manual/en/function.mysql-affected-rows.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With