Bitrix Site Manager

CForumTopic::GetList

CDBResult
GetList(
 [array arOrder [,
 array arFilter [,
 bool bCount [,
 int iNum]]]]
);

The method GetList returns a filtered and sorted list of topics.

Parameters

ParameterDescription
arOrder An array of the format Array(by1=>order1[, by2=>order2 [, ..]]), where:

by - the field by which the list is to be sorted. The following values are possible:
  • ID - the topic ID;
  • TITLE - the topic title;
  • STATE - topic state;
  • USER_START_ID - the ID of the user who has created a topic;
  • USER_START_NAME - the name of the user who has created a topic;
  • START_DATE - the date the topic was created;
  • POSTS - number of posts in the topic;
  • VIEWS - number of topic views;
  • APPROVED - the topic is approved and published.
  • LAST_POST_DATE - the date the last message was created in the topic;
  • SORT - sort index;

order - sort order. The following values are possible:

  • ASC - ascending;
  • DESC - descending;

Optional. The default value is Array("SORT"=>"ASC")

arFilter An array of the format array("filter field"=>"filter value" [, ...]).

The "filter field" can be one of the following:
  • STATE - topic state;
  • FORUM_ID - the forum ID;
  • ID - the topic ID;
  • APPROVED - the topic is approved and published;
  • LAST_POST_DATE - the date the last message was created in the topic;
The filtered field may contain one of the following condition operators before the name:
  • "!" - not equal;
  • "<" - less than;
  • "<=" - less or equal;
  • ">" - more than;
  • ">=" - more or equal.
Optional. By default, records are not filtered.
bCount If parameter is true, only the number of topics that conforms to the specified filter is returned.
Optional. The default value is false.
iNum Maximum number of records returned. If the parameter iNum is not zero, a maximum of iNum records is returned. Not all databases support this feature. If the feature is not supported, this parameter is ignored. Optional. The default value is 0.

Return Values

Returns an instance of the CDBResult class.

See Also

  • CDBResult
  • Topic fields

    Example


    
    <?
    // Select all the published topics of the forum $FID,
    // that were sorted first by sort index,
    // then by the date of the last message in the topic
    $db_res = CForumTopic::GetList(array("SORT"=>"ASC", 
                                         "LAST_POST_DATE"=>"DESC"), 
                                   array("FORUM_ID"=>$FID));
    while ($ar_res = $db_res->Fetch())
    {
      echo $ar_res["TITLE"]."<br>";
    }
    ?>