Skip to content
Permalink
Browse files

Fix comments recount when cleaning the database

  • Loading branch information...
BoboTiG
BoboTiG committed Aug 9, 2013
1 parent 143e3a1 commit b7cd9819678d7d28138ce8933046fca6ee638bca
Showing with 2 additions and 2 deletions.
  1. +2 −2 admin/maintenance.php
4 admin/maintenance.php 100755 → 100644
@@ -1197,10 +1197,10 @@ function is_file_error() {
// recomptage des commentaires
if ($_POST['recount']) {
if ($GLOBALS['sgdb'] == 'sqlite') {
$query = "UPDATE articles SET bt_nb_comments = (SELECT count(a.bt_id) FROM articles a INNER JOIN commentaires c ON (c.bt_article_id = a.bt_id) WHERE articles.bt_id = a.bt_id GROUP BY a.bt_id)";
$query = "UPDATE articles SET bt_nb_comments = COALESCE((SELECT count(a.bt_id) FROM articles a INNER JOIN commentaires c ON (c.bt_article_id = a.bt_id) WHERE articles.bt_id = a.bt_id GROUP BY a.bt_id), 0)";
}
if ($GLOBALS['sgdb'] == 'mysql') {
$query = "UPDATE articles SET bt_nb_comments = (SELECT count(articles.bt_id) FROM commentaires WHERE commentaires.bt_article_id = articles.bt_id)";
$query = "UPDATE articles SET bt_nb_comments = COALESCE((SELECT count(articles.bt_id) FROM commentaires WHERE commentaires.bt_article_id = articles.bt_id), 0)";
}
try {
$req = $GLOBALS['db_handle']->prepare($query);

0 comments on commit b7cd981

Please sign in to comment.
You can’t perform that action at this time.