Backend\Modules\Blog\Engine\Model::deleteSpamComments PHP Method

deleteSpamComments() public static method

Delete all spam
public static deleteSpamComments ( )
    public static function deleteSpamComments()
    {
        $db = BackendModel::getContainer()->get('database');
        // get ids
        $itemIds = (array) $db->getColumn('SELECT i.post_id
             FROM blog_comments AS i
             WHERE status = ? AND i.language = ?', array('spam', BL::getWorkingLanguage()));
        // update record
        $db->delete('blog_comments', 'status = ? AND language = ?', array('spam', BL::getWorkingLanguage()));
        // recalculate the comment count
        if (!empty($itemIds)) {
            self::reCalculateCommentCount($itemIds);
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     BackendBlogModel::deleteSpamComments();
     // item was deleted, so redirect
     $this->redirect(BackendModel::createURLForAction('Comments') . '&report=deleted-spam#tabSpam');
 }