Skip to content

Instantly share code, notes, and snippets.

@batandwa
Created March 20, 2012 11:40
Show Gist options
  • Save batandwa/2134373 to your computer and use it in GitHub Desktop.
Save batandwa/2134373 to your computer and use it in GitHub Desktop.
Drupal database query example
<?php
$values = array(1, 2, 3, 4, 5);
$placeholders = db_placeholders($values);
$result = db_query("SELECT t.s FROM {table} t WHERE t.field IN ($placeholders)", $values);
$items = array();
while ($row = db_fetch_object($result)) {
$items[] = $row->s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment