public static function deleteComments($ids)
{
// make sure $ids is an array
$ids = (array) $ids;
// loop and cast to integers
foreach ($ids as &$id) {
$id = (int) $id;
}
// create an array with an equal amount of questionmarks as ids provided
$idPlaceHolders = array_fill(0, count($ids), '?');
// get db
$db = BackendModel::getContainer()->get('database');
// get ids
$itemIds = (array) $db->getColumn('SELECT i.post_id
FROM blog_comments AS i
WHERE i.id IN (' . implode(', ', $idPlaceHolders) . ')', $ids);
// update record
$db->delete('blog_comments', 'id IN (' . implode(', ', $idPlaceHolders) . ')', $ids);
// recalculate the comment count
if (!empty($itemIds)) {
self::reCalculateCommentCount($itemIds);
}
}