Przeglądaj źródła

Fix UpdateCountPosts and UpdateCountTopics

Fix for Column cannot be null
Visman 5 lat temu
rodzic
commit
144092326a

+ 2 - 2
app/Models/User/UpdateCountPosts.php

@@ -44,14 +44,14 @@ class UpdateCountPosts extends Action
         }
 
         $query = 'UPDATE ::users AS u
-            SET u.num_posts = (
+            SET u.num_posts = COALESCE((
                 SELECT COUNT(p.id)
                 FROM ::posts AS p
                 INNER JOIN ::topics AS t ON t.id=p.topic_id
                 INNER JOIN ::forums AS f ON f.id=t.forum_id
                 WHERE p.poster_id=u.id AND f.no_sum_mess=0
                 GROUP BY p.poster_id
-            )
+            ), 0)
             WHERE ' . $where;
 
         $this->c->DB->exec($query, $vars);

+ 2 - 2
app/Models/User/UpdateCountTopics.php

@@ -44,13 +44,13 @@ class UpdateCountTopics extends Action
         }
 
         $query = 'UPDATE ::users AS u
-            SET u.num_topics = (
+            SET u.num_topics = COALESCE((
                 SELECT COUNT(t.id)
                 FROM ::topics AS t
                 INNER JOIN ::posts AS p ON t.first_post_id=p.id
                 WHERE p.poster_id=u.id AND t.moved_to=0
                 GROUP BY p.poster_id
-            )
+            ), 0)
             WHERE ' . $where;
 
         $this->c->DB->exec($query, $vars);