Skip to content

Instantly share code, notes, and snippets.

@perusio
Created January 27, 2012 01:57
Show Gist options
  • Save perusio/1686457 to your computer and use it in GitHub Desktop.
Save perusio/1686457 to your computer and use it in GitHub Desktop.
Drupal 7 DBTNG JOIN example
<?php
// Use a JOIN there are aliases.
$select = db_select('url_alias', 'a');
$select->join('node', 'n', 'SUBSTR(a.source, 6) = n.nid');
$pairs = $select->fields('a', array('source', 'alias'))
->orderBy('changed', 'DESC')
->condition('changed', $updated, '>=')
->execute()
->fetchAllKeyed();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment