I think db_query is better, but make sure to clear the cache after the db update.

cache_clear_all('content:'.$node->nid ,'cache_content', TRUE);


孟祥宇
Shawn Meng

blog: http://mengxy.net
twitter: @mengxy


On Wed, Apr 7, 2010 at 5:42 PM, Michel Morelli <michel@ziobuddalabs.it> wrote:
Hi all. I have a content type with a cck integer field and I need to
increment it when user click on a link (user is redirect to another
page, or similar).

To do this I have two option:
1) node_save
2) db_query

This node type has a total of 5 cck fields. Other fields does not change
when user click on that link.
My site would be a trafficated site so I could have 10 or 100 clicks on
that link in a single moment.

I think to this code (for sql query solution):

db_query("LOCK TABLES {content_type_gf_product} WRITE,{watchdog} WRITE");
db_query("UPDATE {content_type_my_type}  set  field_download_stats_value
= field_download_stats_value+1 where nid = %d and vid = %d",
$node->nid,$node->vid);
db_query("UNLOCK TABLES");

Tnx.

--
Michel 'ZioBudda' Morelli                       michel@ziobuddalabs.it
Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ziodrupal.net                        MSN: michel@ziobuddalabs.it
                                               JABBER: michel@ziobuddalabs.it

--
[ Drupal support list | http://lists.drupal.org/ ]