EntityFieldQuery真的效率低下吗?
我是Entity API的认可新手,但正在尝试解决该问题。我正在一个使用多种内容类型并附加了各个字段的网站上工作;没有什么花哨。因此,当我想检索一组条目时,由于无知,我一直直接调用数据库并执行以下操作: $query = db_select('node', 'n')->extend('PagerDefault'); $query->fields('n', array('nid')); $query->condition('n.type', 'my_content_type'); $query->leftJoin('field_data_field_user_role', 'role', 'n.nid = role.entity_id'); $query->condition('role.field_user_role_value', $some_value); $query->leftJoin('field_data_field_withdrawn_time', 'wt', 'n.nid = wt.entity_id'); $query->condition('wt.field_withdrawn_time_value', 0); $query->orderBy('n.created', 'desc'); $query->limit(10); $result = $the_questions->execute()->fetchCol(); (是的,我可能会把这些行折叠成一个$the_questions->语句;请暂时忽略它。) 试图用EntityFieldQuery重写它,我想出了: $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'my_content_type') ->fieldCondition('field_user_role', 'value', $some_value) ->fieldCondition('field_withdrawn_time', 'value', 0) ->propertyOrderBy('created', 'desc') ->pager(10); …