function entity_load
Same name in other branches
- 8.9.x core/includes/entity.inc \entity_load()
Load entities from the database.
The entities are stored in a static memory cache, and will not require database access if loaded again during the same page request.
The actual loading is done through a class that has to implement the DrupalEntityControllerInterface interface. By default, DrupalDefaultEntityController is used. Entity types can specify that a different class should be used by setting the 'controller class' key in hook_entity_info(). These classes can either implement the DrupalEntityControllerInterface interface, or, most commonly, extend the DrupalDefaultEntityController class. See node_entity_info() and the NodeController in node.module as an example.
@todo Remove $conditions in Drupal 8.
Parameters
$entity_type: The entity type to load, e.g. node or user.
$ids: An array of entity IDs, or FALSE to load all entities.
$conditions: (deprecated) An associative array of conditions on the base 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 cache for the requested entity type.
Return value
An array of entity objects indexed by their ids. When no results are found, an empty array is returned.
See also
DrupalEntityControllerInterface
10 calls to entity_load()
- comment_load_multiple in modules/
comment/ comment.module - Load comments from the database.
- EntityLoadTestCase::testEntityLoadConditions in modules/
simpletest/ tests/ entity_crud.test - Tests the functionality for loading entities matching certain conditions.
- EntityLoadTestCase::testEntityLoadIds in modules/
simpletest/ tests/ entity_crud.test - FileTaxonomyTermTestCase::_testTermFile in modules/
file/ tests/ file.test - Runs tests for attaching a file field to a taxonomy term.
- file_file_download in modules/
file/ file.module - Implements hook_file_download().
File
-
includes/
common.inc, line 8176
Code
function entity_load($entity_type, $ids = FALSE, $conditions = array(), $reset = FALSE) {
if ($reset) {
entity_get_controller($entity_type)->resetCache();
}
return entity_get_controller($entity_type)->load($ids, $conditions);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.