2011-08-01 92 views

回答

0

喜欢的东西...

<?php 

// you'll need to include /modules/comment/comment.admin.inc 
module_load_include('inc', 'comment', 'comment.admin'); 

// I'm assuming you have access to the cid, the unique 
// identifier for comments stored in the {comments} table 
$comment = _comment_load($cid); 
_comment_delete_thread($comment); 
_comment_update_node_statistics($comment->nid); 

?> 

该解决方案是为Drupal 6,但可以借用包括注释模块文件,并劫持他们在其他版本的功能了。

我不确定扩展核心论坛功能的贡献模块(如Advanced Forum)是否提供了一个选项,而无需编写自定义代码,但您可能需要查看它。

0

Drupal 7的 使用comment_delete()

<?php 

    //Delete single comment 
    $cid = 3917; //cid from `comment` table 
    comment_delete($cid); 

    //Delete multiple comments 
    $cids = array(137421,137426,137427,137428,137429,137430,137431,137434,137450,137472); 
    foreach ($cids as $cid) { 
     comment_delete($cid);  
    } 
1

在Drupal 7的有comment_delete_multiple()它调用涉及评价缺失钩,并通过_comment_update_node_statistics()更新节点统计信息。它需要一系列评论ID。

在Drupal的6,没有同等的功能,但你写的Drupal 7的功能相当于,考虑到:

  • 的Drupal 6不具备的功能来处理交易
  • 在Drupal的6,删除注释时调用挂钩的名称不同
  • 的Drupal 6没有实体领域
  • 的Drupal 6不具有db_delete()comment_load_multiple()
  • 任何等效