aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php47
1 files changed, 23 insertions, 24 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index f9bdd7be2..e8a531ec0 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -313,7 +313,7 @@ SQL;
*/
public function markFavorite($ids, bool $is_favorite = true) {
if (!is_array($ids)) {
- $ids = array($ids);
+ $ids = [$ids];
}
if (count($ids) < 1) {
return 0;
@@ -331,7 +331,7 @@ SQL;
$sql = 'UPDATE `_entry` '
. 'SET is_favorite=? '
. 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)';
- $values = array($is_favorite ? 1 : 0);
+ $values = [$is_favorite ? 1 : 0];
$values = array_merge($values, $ids);
$stm = $this->pdo->prepare($sql);
if ($stm !== false && $stm->execute($values)) {
@@ -361,7 +361,7 @@ UPDATE `_feed` f LEFT OUTER JOIN (
SET f.`cache_nbUnreads` = COALESCE(x.nbUnreads, 0)
SQL;
$hasWhere = false;
- $values = array();
+ $values = [];
if ($feedId != null) {
$sql .= ' WHERE';
$hasWhere = true;
@@ -419,7 +419,7 @@ SQL;
$sql = 'UPDATE `_entry` '
. 'SET is_read=? '
. 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)';
- $values = array($is_read ? 1 : 0);
+ $values = [$is_read ? 1 : 0];
$values = array_merge($values, $ids);
$stm = $this->pdo->prepare($sql);
if (!($stm && $stm->execute($values))) {
@@ -437,7 +437,7 @@ SQL;
. 'SET e.is_read=?,'
. 'f.`cache_nbUnreads`=f.`cache_nbUnreads`' . ($is_read ? '-' : '+') . '1 '
. 'WHERE e.id=? AND e.is_read=?';
- $values = array($is_read ? 1 : 0, $ids, $is_read ? 0 : 1);
+ $values = [$is_read ? 1 : 0, $ids, $is_read ? 0 : 1];
$stm = $this->pdo->prepare($sql);
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
@@ -484,9 +484,9 @@ SQL;
} elseif ($priorityMin >= 0) {
$sql .= ' AND f.priority > ' . intval($priorityMin);
}
- $values = array($is_read ? 1 : 0, $is_read ? 1 : 0, $idMax);
+ $values = [$is_read ? 1 : 0, $is_read ? 1 : 0, $idMax];
- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);
+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
@@ -522,9 +522,9 @@ SQL;
$sql = 'UPDATE `_entry` e INNER JOIN `_feed` f ON e.id_feed=f.id '
. 'SET e.is_read=? '
. 'WHERE f.category=? AND e.is_read <> ? AND e.id <= ?';
- $values = array($is_read ? 1 : 0, $id, $is_read ? 1 : 0, $idMax);
+ $values = [$is_read ? 1 : 0, $id, $is_read ? 1 : 0, $idMax];
- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);
+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
@@ -564,9 +564,9 @@ SQL;
$sql = 'UPDATE `_entry` '
. 'SET is_read=? '
. 'WHERE id_feed=? AND is_read <> ? AND id <= ?';
- $values = array($is_read ? 1 : 0, $id_feed, $is_read ? 1 : 0, $idMax);
+ $values = [$is_read ? 1 : 0, $id_feed, $is_read ? 1 : 0, $idMax];
- list($searchValues, $search) = $this->sqlListEntriesWhere('', $filters, $state);
+ [$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
@@ -617,14 +617,14 @@ SQL;
. 'WHERE '
. ($id == 0 ? '' : 'et.id_tag = ? AND ')
. 'e.is_read <> ? AND e.id <= ?';
- $values = array($is_read ? 1 : 0);
+ $values = [$is_read ? 1 : 0];
if ($id != 0) {
$values[] = $id;
}
$values[] = $is_read ? 1 : 0;
$values[] = $idMax;
- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);
+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
@@ -769,7 +769,7 @@ SQL;
}
if ($filter instanceof FreshRSS_BooleanSearch) {
// BooleanSearches are combined by AND (default) or OR (special case) operator and are recursive
- list($filterValues, $filterSearch) = self::sqlBooleanSearch($alias, $filter, $level + 1);
+ [$filterValues, $filterSearch] = self::sqlBooleanSearch($alias, $filter, $level + 1);
$filterSearch = trim($filterSearch);
if ($filterSearch !== '') {
@@ -1016,7 +1016,7 @@ SQL;
int $state = FreshRSS_Entry::STATE_ALL,
string $order = 'DESC', string $firstId = '', int $date_min = 0) {
$search = ' ';
- $values = array();
+ $values = [];
if ($state & FreshRSS_Entry::STATE_NOT_READ) {
if (!($state & FreshRSS_Entry::STATE_READ)) {
$search .= 'AND ' . $alias . 'is_read=0 ';
@@ -1048,14 +1048,14 @@ SQL;
$values[] = $date_min . '000000';
}
if ($filters && count($filters->searches()) > 0) {
- list($filterValues, $filterSearch) = self::sqlBooleanSearch($alias, $filters);
+ [$filterValues, $filterSearch] = self::sqlBooleanSearch($alias, $filters);
$filterSearch = trim($filterSearch);
if ($filterSearch !== '') {
$search .= 'AND (' . $filterSearch . ') ';
$values = array_merge($values, $filterValues);
}
}
- return array($values, $search);
+ return [$values, $search];
}
/**
@@ -1071,7 +1071,7 @@ SQL;
$state = FreshRSS_Entry::STATE_ALL;
}
$where = '';
- $values = array();
+ $values = [];
switch ($type) {
case 'a': //All PRIORITY_MAIN_STREAM
$where .= 'f.priority > ' . FreshRSS_Feed::PRIORITY_NORMAL . ' ';
@@ -1109,10 +1109,9 @@ SQL;
throw new FreshRSS_EntriesGetter_Exception('Bad type in Entry->listByType: [' . $type . ']!');
}
- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state, $order, $firstId, $date_min);
+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state, $order, $firstId, $date_min);
- return array(array_merge($values, $searchValues),
- 'SELECT '
+ return [array_merge($values, $searchValues), 'SELECT '
. ($type === 'T' ? 'DISTINCT ' : '')
. 'e.id FROM `_entry` e '
. 'INNER JOIN `_feed` f ON e.id_feed = f.id '
@@ -1120,7 +1119,7 @@ SQL;
. 'WHERE ' . $where
. $search
. 'ORDER BY e.id ' . $order
- . ($limit > 0 ? ' LIMIT ' . intval($limit) : '')); //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
+ . ($limit > 0 ? ' LIMIT ' . intval($limit) : '')]; //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
}
/**
@@ -1257,7 +1256,7 @@ SQL;
$sql = 'SELECT guid, ' . static::sqlHexEncode('hash') .
' AS hex_hash FROM `_entry` WHERE id_feed=? AND guid IN (' . str_repeat('?,', count($guids) - 1). '?)';
$stm = $this->pdo->prepare($sql);
- $values = array($id_feed);
+ $values = [$id_feed];
$values = array_merge($values, $guids);
if ($stm !== false && $stm->execute($values)) {
$rows = $stm->fetchAll(PDO::FETCH_ASSOC);
@@ -1297,7 +1296,7 @@ SQL;
if ($mtime <= 0) {
$mtime = time();
}
- $values = array($mtime, $id_feed);
+ $values = [$mtime, $id_feed];
$values = array_merge($values, $guids);
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();