<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>mIf you can I would always recommend using node_save() since it means that you can have this trigger things or allow other developers to expand on your module without you needing to do anything.</div><div><br></div><div>I have had this where I have needed to extend an operation when a db_query() is used where as if they had used a node_save() all I would need to add a hook_nodeapi() or even it is was not as complex I could use the the rules module to trigger other things to happen.</div><div><br></div><div>I know that it is not as efficient to do a node_save() but it does allow alot more extendability.</div><div><br></div><div>Gordon.</div><div><br><div><div>On 07/04/2010, at 8:23 PM, Shawn(Xiangyu) Meng wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I think db_query is better, but make sure to clear the cache after the db update.<br><br>cache_clear_all('content:'.$node-&gt;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">&lt;<a href="mailto:michel@ziobuddalabs.it">michel@ziobuddalabs.it</a>&gt;</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} &nbsp;set &nbsp;field_download_stats_value<br>
= field_download_stats_value+1 where nid = %d and vid = %d",<br>
$node-&gt;nid,$node-&gt;vid);<br>
db_query("UNLOCK TABLES");<br>
<br>
Tnx.<br>
<br>
--<br>
Michel 'ZioBudda' Morelli &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <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 -- &nbsp;Fax: +39-0291390660<br>
<br>
<a href="http://www.ziobudda.net/" target="_blank">http://www.ziobudda.net</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ICQ: 58351764<br>
<a href="http://www.ziobuddalabs.it/" target="_blank">http://www.ziobuddalabs.it</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Skype: zio_budda<br>
<a href="http://www.ziodrupal.net/" target="_blank">http://www.ziodrupal.net</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MSN: <a href="mailto:michel@ziobuddalabs.it">michel@ziobuddalabs.it</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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>
-- <br>[ Drupal support list | <a href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]</blockquote></div><br></div></body></html>