6

I am trying many options, e.g:

$entities = $nodeQuery->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'article') 
    ->fieldCondition('field_archived','field_archived_value', '1', '=') 
    ->pager(10)
    ->execute();

field_archived is the machine name of my custom field added to article. field_archived_value is a column inside field_data_field_archived table.

In this case I am getting error:

PDOException: SQLSTATE[42S22]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'field_archived_field_archived_value

What I am doing wrong here?

11

The correct code is the following one.

$entities = $nodeQuery->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'article') 
  ->fieldCondition('field_archived','value', '1', '=') 
  ->pager(10)
  ->execute();

Instead of 'field_archived_value' you need to use 'value'.

0

In entity query, you need to write the machine name of the field, not the table name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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