diff options
| author | 2016-10-30 20:15:11 +0100 | |
|---|---|---|
| committer | 2016-10-30 20:15:11 +0100 | |
| commit | 1d3e5bdee069434fd65c2717ae8fcce8c54fe81d (patch) | |
| tree | 39b0ae9ac0b0d1ed7fa11c747a0523cb3faa384b /app/Models/EntryDAOSQLite.php | |
| parent | 17c8c039df675b3b0f8d88d14f7316a240eabe76 (diff) | |
| parent | 29e1f048159b7a580bdf1bab184e928f11d104b4 (diff) | |
Merge pull request #1346 from FreshRSS/dev1.6.0
Merge 1.6.0-dev in master
Diffstat (limited to 'app/Models/EntryDAOSQLite.php')
| -rw-r--r-- | app/Models/EntryDAOSQLite.php | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index dad34a93d..34e854608 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -2,6 +2,10 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { + public function sqlHexDecode($x) { + return $x; + } + protected function autoUpdateDb($errorInfo) { if (empty($errorInfo[0]) || $errorInfo[0] == '42S22') { //ER_BAD_FIELD_ERROR //autoAddColumn @@ -24,17 +28,21 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { protected function updateCacheUnreads($catId = false, $feedId = false) { $sql = 'UPDATE `' . $this->prefix . 'feed` ' - . 'SET cache_nbUnreads=(' + . '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); @@ -82,7 +90,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { } $affected = $stm->rowCount(); if ($affected > 0) { - $sql = 'UPDATE `' . $this->prefix . 'feed` SET cache_nbUnreads=cache_nbUnreads' . ($is_read ? '-' : '+') . '1 ' + $sql = 'UPDATE `' . $this->prefix . 'feed` SET `cache_nbUnreads`=`cache_nbUnreads`' . ($is_read ? '-' : '+') . '1 ' . 'WHERE id=(SELECT e.id_feed FROM `' . $this->prefix . 'entry` e WHERE e.id=?)'; $values = array($ids); $stm = $this->bd->prepare($sql); |
