Hi,
I am using support module for my current projects. This module often runs UPDATE SQL statement and checks db_affected_rows() before issuing INSERT statements like
db_query("UPDATE {support_ticket} SET message_id = '%s', state = %d, priority = %d, client = %d, assigned = %d WHERE nid = %d", isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned, $node->nid);
if (!db_affected_rows()) {
db_query("INSERT INTO {support_ticket} (nid, message_id, state, priority, client, assigned) VALUES(%d, '%s', %d, %d, %d, %d)", $node->nid, isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned);
}
I assume this is with an intention of avoiding duplicate records inserts. However in my case db_affected_rows() mostly returns 0 though a matching row is found in the table.
I guess it is because the values being updated is same as values already available in the row. As a result drupal throws user warning like.