我想得到某个节点的所有注释,我使用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做到这一点?
答案 0 :(得分: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) {
}