Skip to content

Instantly share code, notes, and snippets.

@ruizfrontend
Created April 29, 2013 18:15
Show Gist options
  • Save ruizfrontend/5483539 to your computer and use it in GitHub Desktop.
Save ruizfrontend/5483539 to your computer and use it in GitHub Desktop.
Drupal 7 basic node query
$query = db_select('node', 'n');
$query ->condition('n.type', 'NODETYPE', '=');
$query ->condition('n.status', '1', '=');
$query->join('SOMEFIELDTABLE', 'l', 'n.nid = l.entity_id');
$query->fields('n', array('title', 'nid'));
$query->fields('l', array('FIELDCOLUMNNAME'));
$query->orderBy('n.title');
$result = $query->execute();
foreach ($result as $record) {
$fids[] = $record->FIELDCOLUMNNAME;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment