I think db_query is better, but make sure to clear the cache after the db update.<br><br>cache_clear_all('content:'.$node->nid ,'cache_content', TRUE);<br><br><br clear="all">孟祥宇<br>Shawn Meng<br><br>blog: <a href="http://mengxy.net">http://mengxy.net</a><br>
twitter: @mengxy<br>
<br><br><div class="gmail_quote">On Wed, Apr 7, 2010 at 5:42 PM, Michel Morelli <span dir="ltr"><<a href="mailto:michel@ziobuddalabs.it">michel@ziobuddalabs.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi all. I have a content type with a cck integer field and I need to<br>
increment it when user click on a link (user is redirect to another<br>
page, or similar).<br>
<br>
To do this I have two option:<br>
1) node_save<br>
2) db_query<br>
<br>
This node type has a total of 5 cck fields. Other fields does not change<br>
when user click on that link.<br>
My site would be a trafficated site so I could have 10 or 100 clicks on<br>
that link in a single moment.<br>
<br>
I think to this code (for sql query solution):<br>
<br>
db_query("LOCK TABLES {content_type_gf_product} WRITE,{watchdog} WRITE");<br>
db_query("UPDATE {content_type_my_type} set field_download_stats_value<br>
= field_download_stats_value+1 where nid = %d and vid = %d",<br>
$node->nid,$node->vid);<br>
db_query("UNLOCK TABLES");<br>
<br>
Tnx.<br>
<br>
--<br>
Michel 'ZioBudda' Morelli <a href="mailto:michel@ziobuddalabs.it">michel@ziobuddalabs.it</a><br>
Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax)<br>
Telefono: 0200619074<br>
Telefono Cell: +39-3939890025 -- Fax: +39-0291390660<br>
<br>
<a href="http://www.ziobudda.net" target="_blank">http://www.ziobudda.net</a> ICQ: 58351764<br>
<a href="http://www.ziobuddalabs.it" target="_blank">http://www.ziobuddalabs.it</a> Skype: zio_budda<br>
<a href="http://www.ziodrupal.net" target="_blank">http://www.ziodrupal.net</a> MSN: <a href="mailto:michel@ziobuddalabs.it">michel@ziobuddalabs.it</a><br>
JABBER: <a href="mailto:michel@ziobuddalabs.it">michel@ziobuddalabs.it</a><br>
<font color="#888888"><br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</font></blockquote></div><br>