1 entity.module entity_load($entity_type, $id)

Loads a single entity from the database.

Prior to Backdrop 1.2.0, this function was actually used to load multiple entities and no convenience function for loading a single entity existed. The previous version of this function was renamed to entity_load_multiple() and this function was written to preserve compatibility for modules depending on the previous behavior.

If this function is called with either an array of IDs or FALSE as the $id parameter, the parameters are passed through to entity_load_multiple() and its return value will be returned instead of a single entity.


string $entity_type: The entity type to load, e.g. node or user.

int|array $id: The ID(s) of the entity to load.

Return value

EntityInterface|bool: The fully loaded entity or FALSE if not found.

See also



core/modules/entity/entity.module, line 574
Entity API for handling entities like nodes or users.


function entity_load($entity_type, $id) {
  if (is_array($id) || $id === FALSE || $id === NULL) {
    return call_user_func_array('entity_load_multiple', func_get_args());
  else {
    $result = entity_load_multiple($entity_type, array($id));
    return reset($result);