original_string: public function get_first_post_for_discussion_ids(array $discussionids) : array {
  
          if (empty($discussionids)) {
              return [];
          }
  
          list($insql, $params) = $this->get_db()->get_in_or_equal($discussionids, SQL_PARAMS_NAMED);
  
          $sql = "
              SELECT p.*
                FROM {" . self::TABLE . "} p
                JOIN (
                  SELECT mp.discussion, MIN(mp.created) AS created
                    FROM {" . self::TABLE . "} mp
                   WHERE mp.discussion {$insql}
                GROUP BY mp.discussion
                ) lp ON lp.discussion = p.discussion AND lp.created = p.created";
  
          return $this->get_db()->get_records_sql($sql, $params);
      }
code: public function get_first_post_for_discussion_ids(array $discussionids) : array {
  
          if (empty($discussionids)) {
              return [];
          }
  
          list($insql, $params) = $this->get_db()->get_in_or_equal($discussionids, SQL_PARAMS_NAMED);
  
          $sql = "
              SELECT p.*
                FROM {" . self::TABLE . "} p
                JOIN (
                  SELECT mp.discussion, MIN(mp.created) AS created
                    FROM {" . self::TABLE . "} mp
                   WHERE mp.discussion {$insql}
                GROUP BY mp.discussion
                ) lp ON lp.discussion = p.discussion AND lp.created = p.created";
  
          return $this->get_db()->get_records_sql($sql, $params);
      }
code_tokens: public function get_first_post_for_discussion_ids ( array $ discussionids ) : array { if ( empty ( $ discussionids ) ) { return [ ] ; } list ( $ insql , $ params ) = $ this -> get_db ( ) -> get_in_or_equal ( $ discussionids , SQL_PARAMS_NAMED ) ; $ sql = "
              SELECT p.*
                FROM {" . self :: TABLE . "} p
                JOIN (
                  SELECT mp.discussion, MIN(mp.created) AS created
                    FROM {" . self :: TABLE . "} mp
                   WHERE mp.discussion {$insql}
                GROUP BY mp.discussion
                ) lp ON lp.discussion = p.discussion AND lp.created = p.created" ; return $ this -> get_db ( ) -> get_records_sql ( $ sql , $ params ) ; }
docstring: Get a mapping of the first post in each discussion based on post creation time.
  
  @param   int[]        $discussionids The list of discussions to fetch counts for
  @return  stdClass[]   The post object of the first post for each discussions returned in an associative array
docstring_tokens: Get a mapping of the first post in each discussion based on post creation time .