function _getAllPosts($table, $num, $pId = 0, $orderType = 'ASC') { if ($orderType == 'DESC') { $op = '<'; $key = 'minPid'; } else { $op = '>'; $key = 'maxPid'; } $sql = sprintf("SELECT * FROM %s\n\t\t\t\tWHERE pid %s %d\n\t\t\t\tORDER BY pid %s\n\t\t\t\tLIMIT %d", $table, $op, $pId, $orderType, $num); $query = DB::query($sql); $result = array(); $tIds = $authors = array(); while ($post = DB::fetch($query)) { $result[$key] = $post['pid']; if ($post['invisible'] == 0) { $result['data'][$post['pid']] = SearchHelper::convertPost($post); } } return $result; }
function getThreadPosts($tIds) { $result = array(); foreach ($tIds as $postTableId => $_tIds) { $suffix = $postTableId ? "_{$postTableId}" : ''; $sql = sprintf("SELECT * FROM %s\n\t\t\t\t\t\t WHERE tid IN (%s) AND first = 1", DB::table('forum_post' . $suffix), implode($_tIds, ', ')); $query = DB::query($sql); while ($post = DB::fetch($query)) { $result[$post['tid']] = SearchHelper::convertPost($post); } } return $result; }