- $r = q("SELECT %s
- FROM `term`
- STRAIGHT_JOIN `item` ON `item`.`id`=`term`.`oid` %s
- WHERE %s AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s'
- ORDER BY term.created DESC LIMIT %d , %d ",
- item_fieldlists(), item_joins(), item_condition(),
- intval(local_user()),
- intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)),
- intval($a->pager['start']), intval($a->pager['itemspage']));
- } else {
- logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
+ $condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`))
+ AND `otype` = ? AND `type` = ? AND `term` = ?",
+ local_user(), TERM_OBJ_POST, TERM_HASHTAG, $search];
+ $params = ['order' => ['created' => true],
+ 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
+ $terms = DBA::select('term', ['oid'], $condition, $params);
+
+ $itemids = [];
+ while ($term = DBA::fetch($terms)) {
+ $itemids[] = $term['oid'];
+ }
+ DBA::close($terms);