Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query = db_select('taxonomy_index', 't1');
- $query->distinct();
- $query->join('node', 't2', 't1.nid = t2.nid');
- $query->join('taxonomy_term_data', 't3', 't3.tid = t1.tid');
- $query->fields('t1', array('tid'));
- $query->fields('t3', array('name'));
- $query->fields('t1', array('nid'));
- $query->groupBy('t1.nid');
- $query->condition('t2.type', 'article', '=');
- $query->condition('t3.vid', '2', '=');
- $query->orderBy('t2.created', 'DESC');
- $query->range(0, 20);
- $result = $query->execute()->fetchAll();
- print_r($result);
- tid name nid
- 1 apple 200
- 5 orange 165
- 9 grapes 130
- 5 orange 106
- tid name nid
- 1 apple 200
- 5 orange 165
- 9 grapes 130
Add Comment
Please, Sign In to add comment