bratsun
1/29/2015 - 9:17 AM

Fetch node of certain type from DB via db_select

Fetch node of certain type from DB via db_select

$nids = db_select('node', 'n')
  ->fields('n', array('nid'))
  ->fields('n', array('type'))
  ->condition('n.type', 'blog')
  ->execute()
  ->fetchCol(); // returns an indexed array
// Now return the node objects.
$nodes = node_load_multiple($nids);
//print dpm($nodes);

$rnodes = array_reverse($nodes);