Skip to content

Instantly share code, notes, and snippets.

@davidlfox
Last active August 29, 2015 14:27
Show Gist options
  • Save davidlfox/e63d46943e92e021b07b to your computer and use it in GitHub Desktop.
Save davidlfox/e63d46943e92e021b07b to your computer and use it in GitHub Desktop.
attempting to fetch a set of drupal content nodes, ordered by field_weight property
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->propertyCondition('type', 'carousel_image')
->propertyCondition('status', 1)
->fieldOrderBy(‘field_weight', 'ASC')
->execute();
$nodes = node_load_multiple(array_keys($entities['node']));
@davidlfox
Copy link
Author

error:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_weight0.field_weight_ASC' in 'order clause': SELECT field_data_field_weight0.entity_type AS entity_type, field_data_field_weight0.entity_id AS entity_id, field_data_field_weight0.revision_id AS revision_id, field_data_field_weight0.bundle AS bundle FROM {field_data_field_weight} field_data_field_weight0 INNER JOIN {node} node ON node.nid = field_data_field_weight0.entity_id WHERE (field_data_field_weight0.deleted = :db_condition_placeholder_0) AND (node.type = :db_condition_placeholder_1) AND (node.status = :db_condition_placeholder_2) AND (field_data_field_weight0.entity_type = :db_condition_placeholder_3) ORDER BY field_data_field_weight0.field_weight_ASC ASC; Array ( [:db_condition_placeholder_0] => 0 [:db_condition_placeholder_1] => carousel_image [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => node )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment