Posted By

ReeceMarsland on 12/21/09


Tagged

mysql php db drupal


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

spf13
mbria
tronx
batandwacolani


Drupal db_query example


 / Published in: PHP
 

  1. $values = array(1, 2, 3, 4, 5);
  2.  
  3. $placeholders = db_placeholders($values);
  4.  
  5. $result = db_query("SELECT t.s FROM {table} t WHERE t.field IN ($placeholders)", $values);
  6.  
  7. $items = array();
  8. while ($row = db_fetch_object($result)) {
  9. $items[] = l($row->title, "node/{$row->s}");
  10. }

Report this snippet  

You need to login to post a comment.