In my PHP code I have the following SQL statement:
$query = "UPDATE users SET num_logins = num_logins+1, last_login='$timeStamp' WHERE id = $id";
I recently implemented the num_logins column for a project administrator so he could see who the frequent users are. It looks like it is working most of the time, however, I've noticed two users who have num_logins = 0 with timestamp values in the last_login field that fall after the date I implemented the change.
The default for the num_logins column is zero, so if they successfully login, and the above query is the only query that updates their last_login field, how is is that num_logins is still zero when their last_login field has been updated (neither field gets updated anywhere else in the code and I am the only db admin)?
ENGINE=InnoDB.