Community Documentation

node_load

5 node.module node_load($param = array(), $revision = NULL, $reset = NULL)
6 node.module node_load($param = array(), $revision = NULL, $reset = NULL)
7 node.module node_load($nid = NULL, $vid = NULL, $reset = FALSE)
8 node.module 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.

▾ 43 functions call node_load()

blogapi_blogger_edit_post in modules/blogapi/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_get_post in modules/blogapi/blogapi.module
Blogging API callback. Returns a specified blog node.
blogapi_mt_publish_post in modules/blogapi/blogapi.module
Blogging API callback. Publishes the given node
blogapi_mt_set_post_categories in modules/blogapi/blogapi.module
Blogging API callback. Assigns taxonomy terms to a particular node.
blog_form in modules/blog/blog.module
Implementation of hook_form().
blog_page_last in modules/blog/blog.module
Displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.module
Displays a Drupal page containing recent blog entries of a given user.
book_admin_edit in modules/book/book.module
Display an administrative view of the hierarchy of a book.
book_admin_edit_submit in modules/book/book.module
book_admin_orphan in modules/book/book.module
Menu callback; displays a listing of all orphaned book pages.
book_export_html in modules/book/book.module
This function is called by book_export() to generate HTML for export.
book_outline in modules/book/book.module
Implementation of function book_outline() Handles all book outline operations.
book_outline_submit in modules/book/book.module
Handles book outline form submissions.
book_recurse in modules/book/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/comment.module
comment_menu in modules/comment/comment.module
Implementation of hook_menu().
comment_reply in modules/comment/comment.module
This function is responsible for generating a comment reply form. There are several cases that have to be handled, including:
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_access_rebuild in modules/node/node.module
Rebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
node_delete in modules/node/node.module
Delete a node.
node_feed in modules/node/node.module
A generic function for generating RSS feeds from a set of nodes.
node_menu in modules/node/node.module
Implementation of hook_menu().
node_page_default in modules/node/node.module
Menu callback; Generate a listing of promoted nodes.
node_revisions in modules/node/node.module
Menu callback for revisions related activities.
node_revision_delete in modules/node/node.module
Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a revision is deleted.
node_revision_revert in modules/node/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_save in modules/node/node.module
Save a node object into the database.
node_search in modules/node/node.module
Implementation of hook_search().
node_update_index in modules/node/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. Uses the arg() function to generate a series of page template files suggestions based on the current path. If none are found, the default page.tpl.php…
poll_block in modules/poll/poll.module
Implementation of hook_block().
poll_cancel in modules/poll/poll.module
Callback for canceling a vote
poll_menu in modules/poll/poll.module
Implementation of hook_menu().
poll_results in modules/poll/poll.module
Callback for the 'results' tab for polls you can vote on
poll_vote in modules/poll/poll.module
Callback for processing a vote
poll_votes in modules/poll/poll.module
Callback for the 'votes' tab for polls you can see other votes on
profile_block in modules/profile/profile.module
Implementation of hook_block().
statistics_node_tracker in modules/statistics/statistics.module
taxonomy_render_nodes in modules/taxonomy/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/upload.module
upload_js in modules/upload/upload.module
Menu-callback for JavaScript-based uploads.
_book_admin_table_tree in modules/book/book.module

File

modules/node/node.module, line 542
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

<?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_table($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.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.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