查询drupal 7中的文章

时间:2011-12-13 16:54:26

标签: mysql sql drupal

我需要一个MySQL查询(标准SQL)来从drupal 7(标题,图像,正文,发布日期)获取文章信息。只有最后一次修订。

2 个答案:

答案 0 :(得分:1)

听起来像是想要EntityFieldQuery

$query = new EntityFieldQuery;
$results = $query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'article')
  ->execute();

if (isset($results['node'])) {
  $nodes = node_load_multiple(array_keys($results['node']));

  foreach ($nodes as $node) {
    $created = $node->created;
    $image_uri = $node->field_image[$node->language][0]['uri'];
    // ...
  }
}

答案 1 :(得分:1)

好的,我找到了解决方案:

SELECT     node.title, body.body_value, FROM_UNIXTIME(node.created) AS Created, file_managed.uri AS image
FROM         node INNER JOIN
                  field_data_body AS body ON node.nid = body.entity_id INNER JOIN
                  file_usage ON file_usage.id = node.nid INNER JOIN
                  file_managed ON file_usage.fid = file_managed.fid
WHERE     (node.type = 'article')