summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-04-14 10:51:09 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2015-04-14 10:51:09 +0200
commit53eccb2ff78f6d94355cfca3cbfefc981e5de03b (patch)
treed03d66d896b19638fea6140e2b1eb1f7ae707841 /db
parent2c194953f0ff0f24b7f9a18815ec80971871951a (diff)
more phpdoc and remove unused code
Diffstat (limited to 'db')
-rw-r--r--db/itemmapper.php16
-rw-r--r--db/mysql/itemmapper.php1
-rw-r--r--db/newsmapper.php1
-rw-r--r--db/statusflag.php10
4 files changed, 16 insertions, 12 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php
index 0ea3b77fc..cc12a2bd0 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -49,19 +49,18 @@ class ItemMapper extends NewsMapper {
// WARNING: Potential SQL injection if you change this carelessly
$sql = 'AND ((`items`.`status` & ' . $status . ') = ' . $status . ') ';
-
- foreach ($search as $_) {
- $sql .= 'AND `items`.`search_index` LIKE ? ';
- }
-
+ $sql .= str_repeat('AND `items`.`search_index` LIKE ? ', count($search));
$sql .= $prependTo;
return $this->makeSelectQuery($sql, $oldestFirst);
}
- /**
- * wrap and escape search parameters in a like statement
- */
+ /**
+ * wrap and escape search parameters in a like statement
+ *
+ * @param string[] $search an array of strings that should be searched
+ * @return array with like parameters
+ */
private function buildLikeParameters($search=[]) {
return array_map(function ($param) {
$param = addcslashes($param, '\\_%');
@@ -262,6 +261,7 @@ class ItemMapper extends NewsMapper {
/**
* Delete all items for feeds that have over $threshold unread and not
* starred items
+ * @param int $threshold the number of items that should be deleted
*/
public function deleteReadOlderThanThreshold($threshold){
$status = StatusFlag::STARRED | StatusFlag::UNREAD;
diff --git a/db/mysql/itemmapper.php b/db/mysql/itemmapper.php
index 61d32a821..5fb28880b 100644
--- a/db/mysql/itemmapper.php
+++ b/db/mysql/itemmapper.php
@@ -28,6 +28,7 @@ class ItemMapper extends \OCA\News\Db\ItemMapper {
/**
* Delete all items for feeds that have over $threshold unread and not
* starred items
+ * @param int $threshold the number of items that should be deleted
*/
public function deleteReadOlderThanThreshold($threshold){
$status = StatusFlag::STARRED | StatusFlag::UNREAD;
diff --git a/db/newsmapper.php b/db/newsmapper.php
index 5f857d8ee..eea69df2a 100644
--- a/db/newsmapper.php
+++ b/db/newsmapper.php
@@ -14,7 +14,6 @@
namespace OCA\News\Db;
use OCP\IDBConnection;
-use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\Mapper;
abstract class NewsMapper extends Mapper {
diff --git a/db/statusflag.php b/db/statusflag.php
index a3bfd4b18..d91fd0280 100644
--- a/db/statusflag.php
+++ b/db/statusflag.php
@@ -20,9 +20,13 @@ class StatusFlag {
const UPDATED = 0x16;
- /**
- * Get status for query
- */
+ /**
+ * Get status for query
+ *
+ * @param int $type the type that should be turned into the status
+ * @param bool $showAll true if it should return all read items
+ * @return int the status for the database
+ */
public function typeToStatus($type, $showAll){
if($type === FeedType::STARRED){
return self::STARRED;