Community Documentation

node_load_multiple

7 node.module node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE)
8 node.module node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE)

Load node entities from the database.

This function should be used whenever you need to load more than one node from the database. Nodes are loaded into memory and will not require database access if loaded again during the same page request.

@todo Remove $conditions in Drupal 8.

Parameters

$nids: An array of node IDs.

$conditions: (deprecated) An associative array of conditions on the {node} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.

$reset: Whether to reset the internal node_load cache.

Return value

An array of node objects indexed by nid.

See also

entity_load()

EntityFieldQuery

▾ 14 functions call node_load_multiple()

blog_page_last in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
DrupalWebTestCase::drupalGetNodeByTitle in modules/simpletest/drupal_web_test_case.php
Get a node from the database based on its title.
NodeLoadHooksTestCase::testHookNodeLoad in modules/node/node.test
Test that hook_node_load() is invoked correctly.
NodeLoadMultipleUnitTest::testNodeMultipleLoad in modules/node/node.test
Create four nodes and ensure they're loaded correctly.
node_admin_nodes in modules/node/node.admin.inc
Form builder: Builds the node administration overview.
node_delete_multiple in modules/node/node.module
Delete multiple nodes.
node_feed in modules/node/node.module
Generates and prints an RSS feed.
node_get_recent in modules/node/node.module
Finds the most recently changed nodes that are available to the current user.
node_load in modules/node/node.module
Load a node object from the database.
node_page_default in modules/node/node.module
Menu callback; Generate a listing of promoted nodes.
taxonomy_term_page in modules/taxonomy/taxonomy.pages.inc
Menu callback; displays all nodes associated with a term.
UpgradePathTaxonomyTestCase::testTaxonomyUpgrade in modules/simpletest/tests/upgrade/upgrade.taxonomy.test
Basic tests for the taxonomy upgrade.
_node_access_rebuild_batch_operation in modules/node/node.module
Batch operation for node_access_rebuild_batch.

File

modules/node/node.module, line 907
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_multiple($nids = array(), $conditions = array(), $reset = FALSE) {
  return entity_load('node', $nids, $conditions, $reset);
}
?>

Comments

Argument length

The number of nodes that can be loaded into memory in a single query is limited by the PDO layer, the database driver, configuration details, and of course, available memory. Passing too large an argument array to this function can result in the cryptic error message General error: 1 too many SQL variables.

A documentation bug has been posted to note the limited argument length.

How to load nodes of two content types using node_load_multiple?

Hi All,
Greetings for the day.

I have a problem:
I want to load nodes to two content types.
Right now, in node_load_multiple(), you can add a condition of "type".
But, I am unsure about whether it will work for two content types or not.

Can somebody please guide me?

Thanks.

Login or register to post comments