ccache_cleanup: fix sql syntax for mysql

This commit is contained in:
Andrew Dolgov 2011-08-21 16:36:08 +04:00
parent 4dd369d42a
commit cd9da66363
1 changed files with 27 additions and 8 deletions

View File

@ -6125,15 +6125,34 @@
function ccache_cleanup($link, $owner_uid) { function ccache_cleanup($link, $owner_uid) {
db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE if (DB_TYPE == "pgsql") {
(SELECT count(*) FROM ttrss_counters_cache AS c2 db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1 (SELECT count(*) FROM ttrss_counters_cache AS c2
AND owner_uid = '$owner_uid'"); WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
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'"); 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) { function label_find_id($link, $label, $owner_uid) {