From: Andrew Dolgov Date: Tue, 19 Sep 2006 04:16:42 +0000 (+0100) Subject: optimize mark selected function X-Git-Tag: 1.2.3~6 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=18eddb2cb9b58c015e2cc04dd0d41008a03961a4;p=tt-rss.git optimize mark selected function --- diff --git a/backend-rpc.php b/backend-rpc.php index 6de87aa8..92fe2346 100644 --- a/backend-rpc.php +++ b/backend-rpc.php @@ -164,25 +164,10 @@ if ($subop == "markSelected") { $ids = split(",", db_escape_string($_GET["ids"])); - $cmode = sprintf("%d", $_GET["cmode"]); - foreach ($ids as $id) { - - if ($cmode == 0) { - db_query($link, "UPDATE ttrss_user_entries SET - marked = false - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } else if ($cmode == 1) { - db_query($link, "UPDATE ttrss_user_entries SET - marked = true - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } else { - db_query($link, "UPDATE ttrss_user_entries SET - marked = NOT marked - WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); - } - } + markArticlesById($link, $ids, $cmode); + print ""; print ""; getAllCounters($link); diff --git a/functions.php b/functions.php index bb80cac5..600a776c 100644 --- a/functions.php +++ b/functions.php @@ -2587,6 +2587,31 @@ } } + function markArticlesById($link, $ids, $cmode) { + + $tmp_ids = array(); + + foreach ($ids as $id) { + array_push($tmp_ids, "ref_id = '$id'"); + } + + $ids_qpart = join(" OR ", $tmp_ids); + + if ($cmode == 0) { + db_query($link, "UPDATE ttrss_user_entries SET + marked = false,last_read = NOW() + WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]); + } else if ($cmode == 1) { + db_query($link, "UPDATE ttrss_user_entries SET + marked = true + WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]); + } else { + db_query($link, "UPDATE ttrss_user_entries SET + marked = NOT marked,last_read = NOW() + WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]); + } + } + function catchupArticlesById($link, $ids, $cmode) { $tmp_ids = array();