$query = 'SELECT DISTINCT(t.nid), n.nid, n.title FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid WHERE n.nid != %d AND (';
// except the current node
$args = array($node->nid);
$tids = array();
foreach ($node->taxonomy as $term) {
$tids[] = 't.tid = %d';
$args[] = $term->tid;
}
$query .= implode(' OR ', $tids) . ')';
查询代码由大师编写。但我不明白其余的AND('; ... part.hope有人可以为我解释。谢谢。
答案 0 :(得分:2)
查看已完成的查询(echo $query;
),它将变得更加清晰。