0

I tried using entityquery for comment by nid but its not working here is my code :

$query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'comment')
    ->entityCondition('entity_id', 257, '=')
    ->addMetaData('account', user_load(1));

and also I tried changing to nid but still its showing all the comments instead of by specific nid:

$query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'comment')
    ->entityCondition('nid', 257, '=')
    ->addMetaData('account', user_load(1));

can someone tell me I am doing anything wrong?

thank you

1 Answer 1

1

nid is a property of the comment entity, so try:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'comment')
    ->propertyCondition('nid', 257)
    ->addMetaData('account', user_load(1));
1
  • you rock!! it solves my problem in a blast! :)
    – Boby
    Commented Nov 12, 2015 at 20:35

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.