0

我想获取某个节点的所有评论,我使用 db_query。效果很好。但我不能按创建时间订购。我收到 PHP Parse 错误:语法错误,意外的 T_STRING

$results = db_query('SELECT c.nid,c.name, c.uid, c.subject, c.created FROM {comment} c WHERE c.nid = :nid', array(':nid' => $node_id) ORDER By c.created DESC);
foreach ($results as $result) {

}

我发现可以使用 db_select 来完成,但我想知道如何使用 db_query 来完成?

4

1 回答 1

1

我认为您可能想尝试以下代码:

$results = db_query('SELECT c.nid,c.name, c.uid, c.subject, c.created 
                     FROM {comment} c 
                     WHERE c.nid = :nid 
                     ORDER By c.created 
                     DESC',
array(':nid' => $node_id));
foreach ($results as $result) {

}
于 2014-02-20T08:40:48.660 回答