Skip to content

Instantly share code, notes, and snippets.

@brooke-heaton
Last active June 23, 2017 14:29
Show Gist options
  • Save brooke-heaton/97a622a80690fccd2cfc82809691c907 to your computer and use it in GitHub Desktop.
Save brooke-heaton/97a622a80690fccd2cfc82809691c907 to your computer and use it in GitHub Desktop.
Map Drupal 7 node and url_alias tables
<?php
/**
* The alias table entries are prefixed with the actual path
* /node/nid
*/
function return_node_titles_and_aliases() {
$results = db_query("
SELECT
n.nid, n.title,
a.source, a.alias
FROM {node} n
LEFT JOIN {url_alias} a
ON CONCAT('node/', nid) = source
")->fetchAll();
foreach ($results as $result) {
dpm($result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment