diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-05 22:56:22 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-05 22:56:22 +0200 |
commit | 2d8f76d28f47bc3992c0e86c194fe51427805b54 (patch) | |
tree | d6bac7603c37f24c0e0bdf549c778ba4eb5b640d /db/itemmapper.php | |
parent | 4560ab85567564e59647994331328d8949df6b5a (diff) |
fix statusflag db query bugs and unittests
Diffstat (limited to 'db/itemmapper.php')
-rw-r--r-- | db/itemmapper.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php index ca93a8b2a..daff18466 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -65,6 +65,11 @@ class ItemMapper extends Mapper implements IMapper { // code: we take them variables and we cast the shit out of them $status = (int) $status; + // prepare for the unexpected + if(!is_numeric($status)) { + die(); die(); die('If you can read this something is terribly wrong'); + } + // now im gonna slowly stick them in the query, be careful! return $this->makeSelectQuery( 'AND ((`items`.`status` & ' . $status . ') = ' . $status . ') ' . @@ -89,9 +94,10 @@ class ItemMapper extends Mapper implements IMapper { 'JOIN `*PREFIX*news_items` `items` ' . 'ON `items`.`feed_id` = `feeds`.`id` ' . 'AND `feeds`.`user_id` = ? ' . - 'WHERE ((`items`.`status` & ?) = ?)'; + 'WHERE ((`items`.`status` & ' . StatusFlag::STARRED . ') = ' . + StatusFlag::STARRED . ')'; - $params = array($userId, StatusFlag::STARRED, StatusFlag::STARRED); + $params = array($userId); $result = $this->execute($sql, $params)->fetchRow(); |