You are here

function node_get_by_uuid in Universally Unique IDentifier 6

Returns the node associated with a UUID. Uses db_rewrite_sql() to ensure node_access rules are preserved.

Return value

Either the $node object, or FALSE on failure.

File

./uuid.module, line 159
Main module functions for the uuid module.

Code

function node_get_by_uuid($uuid) {
  $nid = db_result(db_query(db_rewrite_sql("SELECT n.nid\n     FROM {node} AS n\n     INNER JOIN {uuid_node} AS un ON n.nid = un.nid\n     WHERE un.uuid = '%s'"), $uuid));
  if ($nid) {
    return node_load($nid);
  }
  else {
    return FALSE;
  }
}