Hi,<br><br>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 <br><br> 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);<br>
if (!db_affected_rows()) {<br> 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);<br>
}<br><br>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. <br><br>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.<br>
<br><div>
user warning: Duplicate entry '292' for key 'PRIMARY'
query: INSERT INTO support_ticket (nid, message_id, state, priority,
client, assigned) VALUES(292, '', 1, 2, 7, 11) in /sites/all/modules/support/support.module on
line 650.</div><br>I am planning to rewrite all the UPDATE query with SELECT COUNT(*) to fix this. Is there any other workaround available for this ?<br><br>I am using Drupal 6.19, PHP 5.3 and MySQL Server version: 5.1.41-3ubuntu12.6 (Ubuntu).<br>
<br>Thanks in advance. <br><br clear="all"><br>-- <br>Sivaji<br>+91 9941 571 690<br><br><br>