Documentation

GetList

CDBResult CBlogComment::GetList(
 array arOrder = Array("ID"=>"DESC"),
 array arFilter = Array(),
 bool  arGroupBy = false,
 bool  arNavStartParams = false,
 array arSelectFields = Array()
);

Returns list of comments by the arFilter, sorted in the arOrder. Non-static method.

Method parameters

ParameterDescription
arOrder Array of sorting of result. Array of the array("soritng field"=>"sorting direction" [, ...]) type Field for sorting can have the following values:
  • ID - comment ID;
  • POST_ID - blog post ID;
  • BLOG_ID - blog ID;
  • AUTHOR_ID - author's comment ID;
  • TITLE - comment header;
  • POST_TEXT - text of comment;
  • DATE_CREATE - date when comment is created;
  • PARENT_ID - parent comment ID;
  • AUTHOR_NAME - name of anonymous comment author;
  • AUTHOR_EMAIL - email of anonymous comment author;
  • AUTHOR_IP - comment author IP-address;
  • AUTHOR_IP1 - comment author IP-address;
  • USER_LOGIN - login for non-anonymous comment author;
  • USER_NAME - name of non-anonymous comment author;
  • USER_LAST_NAME - last name of non-anonymous comment author;
  • USER_EMAIL - email of non-anonymous comment author.
Optional. By default it is filtered by descension of comment ID.
arFilter Array of the array("filtered field"=>"filter value" [, ...]) type. Filtered field can have the following values:
  • ID - comment ID;
  • POST_ID - blog post ID;
  • BLOG_ID - blog ID;
  • AUTHOR_ID - comment author ID;
  • TITLE - comment header;
  • POST_TEXT - text of comment;
  • DATE_CREATE - date when comment was created;
  • PARENT_ID - parent comment ID;
  • AUTHOR_NAME - name of anonymous comment author;
  • AUTHOR_EMAIL - email of anonymous comment author;
  • AUTHOR_IP - comment author IP-address;
  • AUTHOR_IP1 - comment author IP-address;
  • USER_LOGIN - login for non-anonymous comment author;
  • USER_NAME - name of non-anonymous comment author;
  • USER_LAST_NAME - last name of non-anonymous comment author;
  • USER_EMAIL - email of non-anonymous comment author.
  • PUBLISH_STATUS - blog post publication status;
Type of filtration can be specified in front of filtered field:
  • "!" - not equal
  • "<" - less
  • "<=" - less or equal
  • ">" - more
  • ">=" - more or equal

"filter value" - single value or an array.

Optional. By default, records are not filtered.
arGroupBy Array of fields, by which the records are grouped. The array has the following structure:
array("field_name1",
      "aggregate_function1" => "field_name2", ...)
Any field can be specified as "field_nameN". The following can be specified as aggregate function:
  • COUNT - number count;
  • AVG - average value calculation;
  • MIN - minimal value calculation;
  • MAX - maximum value calculation;
  • SUM - sum calculation.
If the array is empty, the method will return the number of records that satisfy the filter.

Optional. By default - false - means that the result will not be grouped.
arNavStartParams Array of selection parameters. Can contain the following keys:
  • "nTopCount" - number of records returned by the method will be limited from above by the value of this key
  • any key, accepted by the CDBResult::NavQuery method as the third parameter.
Optional. By default - false - means that there are no sample parameters.
arSelectFields Array of record fields, which will be returned by the method. Only those fields that are needed can be specified. If there is a "*" value present in the array - all available fields will be returned.


Optional. By default - empty array() - means that all fields of the request's main table will be returned.

Returned value

CDBResult object is returned.

See Also

  • Blog post comment fields
  • Examples of use

    <?
    // select all comments to the blog post with identifier 1
    $arOrder = Array(
            "ID" => "ASC",
            "DATE_CREATE" => "ASC"
        );
    $arFilter = Array(
            "POST_ID"=>'1'
        );
    $arSelectedFields = Array("ID", "BLOG_ID", "POST_ID", "PARENT_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "AUTHOR_IP", "AUTHOR_IP1", "TITLE", "POST_TEXT", "DATE_CREATE");
    
    $dbComment = CBlogComment::GetList($arOrder, $arFilter, false, false, $arSelectedFields);
    while ($arComment = $dbComment->Fetch())
    {
        print_r($arComment);
    }
    ?>


    © «Bitrix24», 2001-2024
    Up