2

I've got this request.

SELECT COUNT(*), ( SELECT COUNT(*) FROM  `node` WHERE uid = 1 AND type = 'article' )
FROM  `comment` 
WHERE uid = 1

Currently, I'm executing this with 2 different EntityFieldQuery objects.

$query = new EntityFieldQuery;
$result = $query
          ->entityCondition('entity_type', 'node')
          ->propertyCondition('status', 1)
          ->propertyCondition('type', 'article')
          ->propertyCondition('uid', 1)
          ->count()
          ->execute();
$query = new EntityFieldQuery;
$result = $query
          ->entityCondition('entity_type', 'comment')
          ->propertyCondition('uid', 1)
          ->count()
          ->execute();

How can I make only 1 request (EntityFieldQuery, db_select(), or db_query())?

  • How are you doing that with an EntityQuery? EntityQuery doesn't take SQL arguments. You haven't given enough information here. – Jaypan Feb 18 '17 at 1:17
  • @Jaypan check my Edit – guish Feb 18 '17 at 11:32
  • What do you mean by I'm executing this with 2 different EntityQuery.? What is different between the first execution and the other one? – kiamlaluno Feb 18 '17 at 12:41
  • @kiamlaluno the first return all nodes created by uid, and the second return all comments by uid – guish Feb 18 '17 at 16:13

Your Answer

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

Browse other questions tagged or ask your own question.