Bitrix Site Manager

CFormAnswer::GetList

CDBResult
CFormAnswer::GetList(
 int question_id,
 string &by = "s_sort",
 string &order = "asc",
 array filter = array(),
 bool &is_filtered
)

The method GetList returns a list of answers as a CDBResult instanse.

Parameters

Parameter Description
question_id The question ID. 
by Reference to the variable containing the field used to sort the result. The following values are possible:
  • s_id - the answer ID;
  • s_sort - sort index.
order Reference to the variable containing the sort order. The following values are possible:
  • asc - ascending;
  • desc - descending.
filter An array used to filter values. The following keys are possible:
  • ID* - the answer ID (by default the method accepts only the exact matches);
  • ID_EXACT_MATCH - if "N", the method performs loose searches (entry is sufficient) when filtering by the ID;
  • ACTIVE - active state flag. The following values are possible:
  • MESSAGE* - the value of the ANSWER_TEXT parameter (the method performs loose searches by default);
  • MESSAGE_EXACT_MATCH - set to "Y" for exact match searches when filtering by MESSAGE;
  • VALUE* - the value of the ANSWER_VALUE parameter (the method performs loose searches by default);
  • VALUE_EXACT_MATCH - set to "Y" for exact match searches when filtering by VALUE;
  • FIELD_TYPE* - answer field type (the method performs loose searches by default);
  • FIELD_TYPE_EXACT_MATCH - set to "Y" for exact match searches when filtering by FIELD_TYPE;
  • FIELD_PARAM* - the value of the answer field parameter (the method performs loose searches by default);
  • FIELD_PARAM_EXACT_MATCH - set to "Y" for exact match searches when filtering by FIELD_PARAM.
* - complex logic allowed
is_filtered Reference to the variable containing true if the returned list is filtered, or false if the returned list is not filtered.

See Also

Example



<?
$QUESTION_ID = 143; // the question ID

// form the filter array
$arFilter = Array(
    // the answer ID is 589 or 590
    "ID"                      => "589 | 590",
    // we need the ID to match exactly
    "ID_EXACT_MATCH"          => "Y",
    // active state flag
    "ACTIVE"                  => "Y",
    // the value of the ANSWER_TEXT parameter is "yes" or "no"
    "MESSAGE"                 => "yes | no",
    // we need the MESSAGE to match exactly
    "MESSAGE_EXACT_MATCH"     => "Y",
    // type of the answer field is radio-button
    "FIELD_TYPE"              => "radio",
    // we need the FIELD_TYPE to match exactly
    "FIELD_TYPE_EXACT_MATCH"  => "Y",
    // parameter includes the string "checked"
    "FIELD_PARAM"             => "checked",
    // we need just an entry in FIELD_PARAM
    "FIELD_PARAM_EXACT_MATCH" => "N"
);

// obtain the list of all answers to the question #143
$rsAnswers = CFormAnswer::GetList(
    $QUESTION_ID, 
    $by="s_id", 
    $order="desc", 
    $arFilter, 
    $is_filtered
    );
while ($arAnswer = $rsAnswers->Fetch())
{
    echo "<pre>"; print_r($arAnswer); echo "</pre>";
}
?>