]> git.wh0rd.org Git - tt-rss.git/commitdiff
ccache_cleanup: fix sql syntax for mysql
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 21 Aug 2011 12:36:08 +0000 (16:36 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 21 Aug 2011 12:36:08 +0000 (16:36 +0400)
functions.php

index 0c58196567f0892537862347d6e49f128bc6dc85..f17fe4484ea998fe3ca84fe21b01a9cd331df0ec 100644 (file)
 
        function ccache_cleanup($link, $owner_uid) {
 
-               db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
-                       (SELECT count(*) FROM ttrss_counters_cache AS c2
-                               WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
-                               AND owner_uid = '$owner_uid'");
-
-               db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE
-                       (SELECT count(*) FROM ttrss_cat_counters_cache AS c2
-                               WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
+               if (DB_TYPE == "pgsql") {
+                       db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
+                               (SELECT count(*) FROM ttrss_counters_cache AS c2
+                                       WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
+                                       AND owner_uid = '$owner_uid'");
+
+                       db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE
+                               (SELECT count(*) FROM ttrss_cat_counters_cache AS c2
+                                       WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
                                        AND owner_uid = '$owner_uid'");
+               } else {
+                       db_query($link, "DELETE c1 FROM
+                                       ttrss_counters_cache AS c1,
+                                       ttrss_counters_cache AS c2
+                               WHERE
+                                       c1.owner_uid = '$owner_uid' AND
+                                       c1.owner_uid = c2.owner_uid AND
+                                       c1.feed_id = c2.feed_id");
+
+                       db_query($link, "DELETE c1 FROM
+                                       ttrss_cat_counters_cache AS c1,
+                                       ttrss_cat_counters_cache AS c2
+                               WHERE
+                                       c1.owner_uid = '$owner_uid' AND
+                                       c1.owner_uid = c2.owner_uid AND
+                                       c1.feed_id = c2.feed_id");
+
+               }
        }
 
        function label_find_id($link, $label, $owner_uid) {