I've used field_info_instances function to retrieve all fields info under a content type.


As from API page,

  1. If $entity_type is not set, return all instances keyed by entity type and bundle name.
  2. If $entity_type is set, return all instances for that entity type, keyed by bundle name.
  3. If $entity_type and $bundle_name are set, return all instances for that bundle.

I didn't get the third point here. what is the default order for return output by file_info_instances when $entity_type and $bundle_name given.

Any idea?

1 Answer 1


This is the query run by field_read_instances():

$query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC));

$query->join('field_config', 'fc', 'fc.id = fci.field_id');

// Turn the conditions into a query.
foreach ($params as $key => $value) {
  $query->condition('fci.' . $key, $value);
if (!$include_inactive) {
  $query->condition('fc.active', 1)->condition('fc.storage_active', 1);
if (!$include_deleted) {
  $query->condition('fc.deleted', 0);
  $query->condition('fci.deleted', 0);

$instances = array();
$results = $query->execute();

So it's safe to say there's no default order for field instances; they'll be in whatever order they went into the database, or perhaps different depending on your DBMS and settings.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.