Drupal 6查询多个表

时间:2013-01-29 22:59:45

标签: php mysql drupal

使用Drupal 6查询语法时出现问题。我的查询可以自行完成:

SELECT term_node.tid, term_data.name FROM term_node, term_data WHERE nid = 22640

以下是我将其转换为与drupal 6一起使用时的内容:

$currentTIDs = db_query("SELECT {term_node}.tid, {term_data}.name FROM {term_node}, {term_data} WHERE nid = 22640");

while ($cTids = db_fetch_object ($currentTIDs)) {
array_push($currentTIDsArray, $cTids);
}

drupal_set_message('<pre>' . print_r($currentTIDsArray, TRUE) . '</pre>');

这导致一个空的查询/数组?任何想法?

1 个答案:

答案 0 :(得分:0)

这是正确的方法:

SELECT tn.tid, td.name FROM {term_node} tn, {term_data} td WHERE nid = 22640");