From ac6b191976226918c898c0e62ca7cb606652bf34 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 26 Nov 2017 16:14:16 +0100 Subject: [PATCH] tag cloud: use dba for db request --- include/tags.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/tags.php b/include/tags.php index 6c13b8296..7ea15f0b9 100644 --- a/include/tags.php +++ b/include/tags.php @@ -168,7 +168,8 @@ function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA $item_condition = item_condition(); $sql_options = item_permissions_sql($uid); - $count = intval($count); + $limit = $count ? sprintf("LIMIT %d", intval($count)) : ""; + if ($flags) { if ($flags === 'wall') { $sql_options .= " AND `item`.`wall` "; @@ -180,16 +181,15 @@ function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA } // Fetch tags - $r = q("SELECT `term`, COUNT(`term`) AS `total` FROM `term` + $r = dba::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term` LEFT JOIN `item` ON `term`.`oid` = `item`.`id` - WHERE `term`.`uid` = %d AND `term`.`type` = %d - AND `term`.`otype` = %d + WHERE `term`.`uid` = ? AND `term`.`type` = ? + AND `term`.`otype` = ? AND $item_condition $sql_options - GROUP BY `term` ORDER BY `total` DESC %s", - intval($uid), - intval($type), - intval(TERM_OBJ_POST), - ((intval($count)) ? "LIMIT $count" : '') + GROUP BY `term` ORDER BY `total` DESC ? $limit", + $uid, + $type, + TERM_OBJ_POST ); if(!DBM::is_result($r)) { return array();