2011-12-13 73 views
-1

我需要一個MySQL查詢(標準SQL)從drupal 7(標題,圖片,正文,發佈日期)獲取文章信息。只有上次修訂。查詢在Drupal 7中的文章

+0

你不能使用Views模塊查看任何理由嗎? –

+0

感謝clive,但我需要一個stardard SQL查詢,因爲我打算從ASP.NET使用它。 – George

回答

0

好吧,我發現了一個解決方案:

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') 
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']; 
    // ... 
    } 
}