$sql = 'SELECT COUNT(*) AS count FROM ' . $this->prefix . 'entry e INNER JOIN ' . $this->prefix . 'feed f ON e.id_feed = f.id WHERE priority > 0';
public function countUnreadRead () {
$sql = 'SELECT is_read, COUNT(*) AS count FROM ' . $this->prefix . 'entry e INNER JOIN ' . $this->prefix . 'feed f ON e.id_feed = f.id WHERE priority > 0 GROUP BY is_read';
$stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
$readUnread = array('unread' => 0, 'read' => 0);
foreach ($res as $line) {
switch (intval($line['is_read'])) {
case 0: $readUnread['unread'] = intval($line['count']); break;
case 1: $readUnread['read'] = intval($line['count']); break;
}
}
return $readUnread;
}
public function countNotRead () {
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->prefix . 'entry e INNER JOIN ' . $this->prefix . 'feed f ON e.id_feed = f.id WHERE is_read=0 AND priority > 0';
$stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
public function count () { //Deprecated: use countUnreadRead() instead
$unreadRead = $this->countUnreadRead (); //This makes better use of caching
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->prefix . 'entry WHERE is_read = 0 AND id_feed = ?';
$stm = $this->bd->prepare ($sql);
$stm->execute (array ($id));
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
}
public function countNotReadByCat ($id) {
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->prefix . 'entry e INNER JOIN ' . $this->prefix . 'feed f ON e.id_feed = f.id WHERE is_read=0 AND category = ?';
$stm = $this->bd->prepare ($sql);
$stm->execute (array ($id));
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
public function countNotRead () { //Deprecated: use countUnreadRead() instead
$unreadRead = $this->countUnreadRead (); //This makes better use of caching
return $unreadRead['unread'];
}
public function countNotReadFavorites () {
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->prefix . 'entry WHERE is_read=0 AND is_favorite=1';
public function countUnreadReadFavorites () {
$sql = 'SELECT is_read, COUNT(*) AS count FROM ' . $this->prefix . 'entry WHERE is_favorite=1 GROUP BY is_read';
$stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
$readUnread = array('unread' => 0, 'read' => 0);
foreach ($res as $line) {
switch (intval($line['is_read'])) {
case 0: $readUnread['unread'] = intval($line['count']); break;
case 1: $readUnread['read'] = intval($line['count']); break;
}
}
return $readUnread;
}
public function countFavorites () {
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->prefix . 'entry WHERE is_favorite=1';
$stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
public function countFavorites () { //Deprecated: use countUnreadReadFavorites() instead
$unreadRead = $this->countUnreadReadFavorites (); //This makes better use of caching