diff --git a/backend.php b/backend.php index d850f023..5eb64d10 100644 --- a/backend.php +++ b/backend.php @@ -3,13 +3,22 @@ include "config.php"; - $link = pg_connect(DB_CONN); - + require_once('magpierss/rss_fetch.inc'); + + $link = pg_connect(DB_CONN); + + pg_query("set client_encoding = 'utf-8'"); + $op = $_GET["op"]; if ($op == "feeds") { - $result = pg_query("SELECT * FROM ttrss_feeds ORDER BY title"); + $result = pg_query("SELECT *, + (SELECT count(id) FROM ttrss_entries + WHERE feed_id = ttrss_feeds.id) AS total, + (SELECT count(id) FROM ttrss_entries + WHERE feed_id = ttrss_feeds.id AND unread = true) as unread + FROM ttrss_feeds ORDER BY title"); print "