[development] Problem with db_affected_rows() in MySQL

Nikola Kotur kotnick at gmail.com
Wed Sep 22 10:51:17 UTC 2010

On Wed, 2010-09-22 at 15:05 +0530, sivaji j.g wrote:

> 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. 

Yes, as MySQL documentation clearly states:

For UPDATE statements, the affected-rows value by default is the number
of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag to
mysql_real_connect() when connecting to mysqld, the affected-rows value
is the number of rows “found”; that is, matched by the WHERE clause.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100922/e11b4017/attachment.html 

More information about the development mailing list