public function get_from_discussion_ids(stdClass $user, array $discussionids, bool $canseeprivatereplies) : array {
        if (empty($discussionids)) {
            return [];
        }

        $alias = $this->get_table_alias();

        list($insql, $params) = $this->get_db()->get_in_or_equal($discussionids, SQL_PARAMS_NAMED);
        [
            'where' => $privatewhere,
            'params' => $privateparams,
        ] = $this->get_private_reply_sql($user, $canseeprivatereplies);

        $wheresql = "{$alias}.discussion {$insql} {$privatewhere}";

        $sql = $this->generate_get_records_sql($wheresql, '');
        $records = $this->get_db()->get_records_sql($sql, array_merge($params, $privateparams));

        return $this->transform_db_records_to_entities($records);
    }