Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:36:32+00:00 2026-05-27T20:36:32+00:00

What am I doing wrong. I can’t seem to pull based upon content type

  • 0

What am I doing wrong. I can’t seem to pull based upon content type fields in drupal 7.

function ycs_list($number) {
  $query = db_select('field_data_field_active_image', 'a')
  ->fields('a', array('field_active_image_value', 'entity_id'))
  ->condition('a.field_active_image_value', 1);
  $query->join('node', 'n', 'n.nid = a.entity_id');
  $query
  ->fields('n', array('nid', 'title', 'uid'))
  ->range(0, $number)
  ->addTag('node_access')
  ->execute();
  print $query;
  return $query;
}

This is how the query prints:

SELECT a.field_active_image_value AS field_active_image_value, a.entity_id AS entity_id, n.nid AS nid, n.title AS title, n.uid AS uid FROM {field_data_field_active_image} a INNER JOIN {node} n ON n.nid = a.entity_id WHERE (a.field_active_image_value = :db_condition_placeholder_0) LIMIT 3 OFFSET 0

It looks right and does work directly in mysql. I have to change :db_conditon_placehoder_0 to 1 and it works doing a direct sql query. I want to pull an array of nodes based upon a condition in the active_image field. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:36:33+00:00Added an answer on May 27, 2026 at 8:36 pm

    Without knowing the actual error you’re getting it’s a bit tricky to debug your existing code, but I’d advise using the EntityFieldQuery class to do this instead:

    function ycs_list($number) {
      $query = new EntityFieldQuery;
      $query->entityCondition('entity_type', 'node')
        ->entityCondition('bundle', 'name_of_node_type') // Remove this line if you don't want to specify a particular node type for the query.
        ->fieldCondition('field_active_image', 'value', 1)
        ->range(0, $number)
        ->addTag('node_access');
    
      // Execute the query and check for results.
      $results = $query->execute();
      $nodes = array();
      if ($results && isset($results['node'])) {
        // Load the node objects based on the node ids returned from the query.
        $nodes = node_load_multiple(array_keys($results['node']));
      }
    
      // If nodes matching your conditions were found you now have an array of fully loaded node objects in $nodes.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to figure out what I am doing wrong here. I publish
I must be doing something wrong. I can't seem to execute my CustomValidator's ServerValidate
I can't see what I'm doing wrong. I think it might be one of
Can anyone please point out what im doing wrong with this Stored Procedure please.
Can someone suggest what I am doing wrong? Basically I have a List Items,
Hi can someone tell me what i'm doing wrong in this jquery statement. I
Can someone who is way smarter than I tell me what I'm doing wrong..
Can't for the life of me figure out what I'm doing wrong... Downloaded Kohaml
Ok, I think whatever I'm doing wrong, it's probably blindingly obvious, but I can't
I'm hoping I'm doing something wrong here and someone can point me in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.