You are here

function entity_metadata_table_query in Entity API 7

Callback for querying entity properties having their values stored in the entities main db table.

1 string reference to 'entity_metadata_table_query'
entity_property_query in includes/entity.property.inc
Queries for entities having the given property value.

File

modules/callbacks.inc, line 1079
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_table_query($entity_type, $property, $value, $limit) {
  $properties = entity_get_all_property_info($entity_type);
  $info = $properties[$property] + array(
    'schema field' => $property,
  );
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $entity_type, '=')
    ->propertyCondition($info['schema field'], $value, is_array($value) ? 'IN' : '=')
    ->range(0, $limit);
  $result = $query
    ->execute();
  return !empty($result[$entity_type]) ? array_keys($result[$entity_type]) : array();
}