0

I ran following query on DB through PHPmyAdmin

SELECT * FROM field_data_field_country_feed WHERE entity_id=40848

And it worked and returned me the single row But when I try to implement that in my custom services it is not returning anything.

$result1 = db_query("SELECT * FROM field_data_field_country_feed WHERE entity_id=40848")->fetchAll();
        var_dump($result1);

Please help

8
  • What type of entity is it?
    – vintorg
    Mar 17 '15 at 17:17
  • entity_id is int(10)
    – Kunal
    Mar 17 '15 at 17:18
  • I mean, is it a node? profile2? taxonomy? user? Or, is it a custom entity?
    – vintorg
    Mar 17 '15 at 17:19
  • it is taxonomy term
    – Kunal
    Mar 17 '15 at 17:21
  • And you simply want to get all the data from that field for that particular entity?
    – vintorg
    Mar 17 '15 at 17:23
2

Try:

$taxonomy_term = taxonomy_term_load(40848); // the 40848 is the term id
$field_items = field_get_items('taxonomy', $taxonomy_term, 'field_data_field_country_feed');
6
  • Thanks for the quick reply. I tried that, but it still doesn't work
    – Kunal
    Mar 17 '15 at 17:36
  • Can you dump the items in $field_items and post?
    – vintorg
    Mar 17 '15 at 17:37
  • yes, already did that. It returns bool(false)
    – Kunal
    Mar 17 '15 at 17:38
  • Try this, dump the vals from $taxonomy_term, and post: $taxonomy_term = taxonomy_term_load(40848);
    – vintorg
    Mar 17 '15 at 17:40
  • Hey Thanks for the help, I just cleared the cache and it is working now. :/
    – Kunal
    Mar 17 '15 at 17:48

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.