aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-10-15 00:50:49 +0200
committerGravatar GitHub <noreply@github.com> 2016-10-15 00:50:49 +0200
commit7ec73a91bc2f1c786ada10441db37f42a6b452f4 (patch)
tree3da6594a3081fecd482c77135b062400072d80a9
parentbfb252a0f381c3edfbd09071f7025082ce92c029 (diff)
parentd184478fb4c98e035dca1ebef36a5946d43c6a3a (diff)
Merge pull request #1313 from Alkarex/postgresql-patch
PostgreSQL compatibility boolean
-rw-r--r--app/Models/EntryDAO.php12
-rw-r--r--app/Models/EntryDAOSQLite.php12
2 files changed, 16 insertions, 8 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);
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index fd5d25bf6..34e854608 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -30,15 +30,19 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
$sql = 'UPDATE `' . $this->prefix . 'feed` '
. 'SET `cache_nbUnreads`=('
. 'SELECT COUNT(*) AS nbUnreads FROM `' . $this->prefix . 'entry` e '
- . 'WHERE e.id_feed=`' . $this->prefix . 'feed`.id AND e.is_read=0) '
- . 'WHERE 1';
+ . 'WHERE e.id_feed=`' . $this->prefix . 'feed`.id AND e.is_read=0)';
+ $hasWhere = false;
$values = array();
if ($feedId !== false) {
- $sql .= ' AND id=?';
+ $sql .= $hasWhere ? ' AND' : ' WHERE';
+ $hasWhere = true;
+ $sql .= ' id=?';
$values[] = $feedId;
}
if ($catId !== false) {
- $sql .= ' AND category=?';
+ $sql .= $hasWhere ? ' AND' : ' WHERE';
+ $hasWhere = true;
+ $sql .= ' category=?';
$values[] = $catId;
}
$stm = $this->bd->prepare($sql);