public function get_from_discussion_id(
        stdClass $user,
        int $discussionid,
        bool $canseeprivatereplies,
        string $orderby = 'created ASC'
    ) : array {
        $alias = $this->get_table_alias();

        [
            'where' => $privatewhere,
            'params' => $privateparams,
        ] = $this->get_private_reply_sql($user, $canseeprivatereplies);

        $wheresql = "{$alias}.discussion = :discussionid {$privatewhere}";
        $orderbysql = $alias . '.' . $orderby;

        $sql = $this->generate_get_records_sql($wheresql, $orderbysql);
        $records = $this->get_db()->get_records_sql($sql, array_merge([
            'discussionid' => $discussionid,
        ], $privateparams));

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