From 8375d4ac4cb32fa7de3bfe14c061bde266b822ad Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 10 Jun 2018 08:58:03 +0000 Subject: [PATCH] Notes again --- mod/notes.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/mod/notes.php b/mod/notes.php index f1a82bd457..be9fe0d70a 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -78,6 +78,7 @@ function notes_content(App $a, $update = false) $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' "; + /// @todo We seem to need "Item::count" as function as well $r = q("SELECT COUNT(*) AS `total` FROM `item` %s WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note' @@ -93,26 +94,21 @@ function notes_content(App $a, $update = false) $a->set_pager_itemspage(40); } - $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s - WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note' - AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall` - $sql_extra - ORDER BY `item`.`created` DESC LIMIT %d ,%d ", - item_joins(local_user()), - item_condition(), - intval(local_user()), - intval($a->pager['start']), - intval($a->pager['itemspage']) + $condition = ["`uid` = ? AND `type` = 'note' AND NOT `wall` + AND `id` = `parent` AND `allow_cid` = ?", + local_user(), '<' . $a->contact['id'] . '>']; + $params = ['order' => ['created' => true], + 'limit' => [$a->pager['start'], $a->pager['itemspage']]]; - ); - - $parents_arr = []; - $parents_str = ''; + $r = Item::select(local_user(), ['item_id'], $condition, $params); if (DBM::is_result($r)) { - foreach ($r as $rr) { + $parents_arr = []; + + while ($rr = dba::fetch($r)) { $parents_arr[] = $rr['item_id']; } + dba::close($r); $condition = ['uid' => local_user(), 'parent' => $parents_arr]; $result = Item::select(local_user(), [], $condition);