node_load

Versions
4.6
node_load($conditions, $revision = NULL, $reset = NULL)
4.7 – 6
node_load($param = array(), $revision = NULL, $reset = NULL)
7
node_load($nid = NULL, $vid = NULL, $reset = FALSE)

Load a node object from the database.

Parameters

$param Either the nid of the node or an array of conditions to match against in the database query

$revision Which numbered revision to load. Defaults to the current version.

$reset Whether to reset the internal node_load cache.

Return value

A fully-populated node object.

▾ 45 functions call node_load()

archive_page in modules/archive.module
Menu callback; lists all nodes posted on a given date.
blogapi_blogger_edit_post in modules/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_get_post in modules/blogapi.module
Blogging API callback. Returns a specified blog node.
blogapi_mt_set_post_categories in modules/blogapi.module
Blogging API callback. Assigns taxonomy terms to a particular node.
blogap_mti_publish_post in modules/blogapi.module
Blogging API callback. Publishes the given node
blog_form in modules/blog.module
Implementation of hook_form().
blog_page_last in modules/blog.module
Displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog.module
Displays a Drupal page containing recent blog entries of a given user.
book_admin_edit in modules/book.module
Display an administrative view of the hierarchy of a book.
book_admin_edit_submit in modules/book.module
book_admin_orphan in modules/book.module
Menu callback; displays a listing of all orphaned book pages.
book_export_html in modules/book.module
This function is called by book_export() to generate HTML for export.
book_outline in modules/book.module
Implementation of function book_outline() Handles all book outline operations.
book_outline_submit in modules/book.module
Handles book outline form submissions.
book_recurse in modules/book.module
Traverses the book tree. Applies the $visit_pre() callback to each node, is called recursively for each child of the node (in weight, title order). Finally appends the output of the $visit_post() callback to the output before returning the generated...
comment_form_add_preview in modules/comment.module
comment_menu in modules/comment.module
Implementation of hook_menu().
comment_reply in modules/comment.module
hook_search in developer/hooks/core.php
Define a custom search routine.
hook_update_index in developer/hooks/core.php
Update Drupal's full-text index for this module.
node_delete in modules/node.module
Delete a node.
node_delete_confirm in modules/node.module
Menu callback -- ask for confirmation of node deletion
node_feed in modules/node.module
A generic function for generating RSS feeds from a set of nodes.
node_form_submit in modules/node.module
node_menu in modules/node.module
Implementation of hook_menu().
node_page in modules/node.module
Menu callback; dispatches control to the appropriate operation handler.
node_page_default in modules/node.module
Generate a listing of promoted nodes.
node_revisions in modules/node.module
Menu callback for revisions related activities.
node_revision_delete in modules/node.module
Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a revision is deleted.
node_revision_delete_confirm_submit in modules/node.module
node_revision_revert in modules/node.module
Revert to the revision with the specified revision number. A node and nodeapi "update" event is triggered (via the node_save() call) when a revision is reverted.
node_revision_revert_confirm_submit in modules/node.module
node_save in modules/node.module
Save a node object into the database.
node_search in modules/node.module
Implementation of hook_search().
node_update_index in modules/node.module
Implementation of hook_update_index().
phptemplate_page in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_page function to be passed into a pluggable template engine.
poll_block in modules/poll.module
Implementation of hook_block().
poll_menu in modules/poll.module
Implementation of hook_menu().
poll_results in modules/poll.module
Callback for the 'results' tab for polls you can vote on
poll_vote in modules/poll.module
Callback for processing a vote
profile_block in modules/profile.module
Implementation of hook_block().
statistics_node_tracker in modules/statistics.module
taxonomy_render_nodes in modules/taxonomy.module
Accepts the result of a pager_query() call, such as that performed by taxonomy_select_nodes(), and formats each node along with a pager.
upload_file_download in modules/upload.module
_book_admin_table_tree in modules/book.module

Code

modules/node.module, line 355

<?php
function node_load($param = array(), $revision = NULL, $reset = NULL) {
  static $nodes = array();

  if ($reset) {
    $nodes = array();
  }

  $cachable = ($revision == NULL);
  $arguments = array();
  if (is_numeric($param)) {
    if ($cachable && isset($nodes[$param])) {
      return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
    }
    $cond = 'n.nid = %d';
    $arguments[] = $param;
  }
  else {
    // Turn the conditions into a query.
    foreach ($param as $key => $value) {
      $cond[] = 'n.'. db_escape_string($key) ." = '%s'";
      $arguments[] = $value;
    }
    $cond = implode(' AND ', $cond);
  }

  // Retrieve the node.
  // No db_rewrite_sql is applied so as to get complete indexing for search.
  if ($revision) {
    array_unshift($arguments, $revision);
    $node = db_fetch_object(db_query('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond, $arguments));
  }
  else {
    $node = db_fetch_object(db_query('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments));
  }

  if ($node->nid) {
    // Call the node specific callback (if any) and piggy-back the
    // results to the node or overwrite some values.
    if ($extra = node_invoke($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }

    if ($extra = node_invoke_nodeapi($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }
    if ($cachable) {
      $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
    }
  }

  return $node;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.