diff options
| author | 2016-10-14 23:05:05 +0200 | |
|---|---|---|
| committer | 2016-10-14 23:05:05 +0200 | |
| commit | d184478fb4c98e035dca1ebef36a5946d43c6a3a (patch) | |
| tree | 2d95a49c1e28f2f57bc40c158c6280967278b087 /app/Models/EntryDAO.php | |
| parent | 1013c7d2e2d8a2331b47859e918f4e6ac45aef63 (diff) | |
PostgreSQL compatibility boolean
https://github.com/FreshRSS/FreshRSS/issues/1311
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 6563b0f93..938d90886 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -273,15 +273,19 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { . 'WHERE e.is_read=0 ' . 'GROUP BY e.id_feed' . ') x ON x.id_feed=f.id ' - . 'SET f.`cache_nbUnreads`=COALESCE(x.nbUnreads, 0) ' - . 'WHERE 1'; + . 'SET f.`cache_nbUnreads`=COALESCE(x.nbUnreads, 0)'; + $hasWhere = false; $values = array(); if ($feedId !== false) { - $sql .= ' AND f.id=?'; + $sql .= $hasWhere ? ' AND' : ' WHERE'; + $hasWhere = true; + $sql .= ' f.id=?'; $values[] = $id; } if ($catId !== false) { - $sql .= ' AND f.category=?'; + $sql .= $hasWhere ? ' AND' : ' WHERE'; + $hasWhere = true; + $sql .= ' f.category=?'; $values[] = $catId; } $stm = $this->bd->prepare($sql); |
