]> git.mxchange.org Git - friendica.git/commitdiff
tag cloud: use dba for db request
authorrabuzarus <>
Sun, 26 Nov 2017 15:14:16 +0000 (16:14 +0100)
committerrabuzarus <>
Sun, 26 Nov 2017 15:14:16 +0000 (16:14 +0100)
include/tags.php

index 6c13b82962f9e0b6103b5a8628f667d2e63432ed..7ea15f0b982d14820a9c27122ed8abe43bd35cf8 100644 (file)
@@ -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();