Documentation

GetDataByID

array
CFormResult::GetDataByID(
 int result_id,
 array field,
 array &result,
 array &answer
)

Returns an array describing the values of answers to questions or the values of web form fields for the specified result. Additionally, this method returns an array, containing the result fields. Non-static method.

Format of array, returned by the method:

Array
(
  [symbol ID of the question 1] => array describing answers to question 1
    Array
      (
        [0] => array describing the answer 1
          Array
          (
            [RESULT_ID]           => result ID
            [FIELD_ID]            => question ID
            [SID]                 => question symbol ID
            [TITLE]               => question text
            [TITLE_TYPE]          => question text type [text|html]
            [FILTER_TITLE]        => filter field title
            [RESULTS_TABLE_TITLE] => title of the table result column
            [ANSWER_ID]           => answer ID
            [ANSWER_TEXT]         => answer parameter ANSWER_TEXT
            [ANSWER_VALUE]        => answer parameter ANSWER_VALUE
            [USER_TEXT]           => typed text
            [USER_DATE]           => input date (if FIELD_TYPE=date)
            [USER_FILE_ID]        => file ID (if FIELD_TYPE=[file|image])
            [USER_FILE_NAME]      => file name
            [USER_FILE_IS_IMAGE]  => "Y" - FIELD_TYPE=image; "N" - FIELD_TYPE=file 
            [USER_FILE_HASH]      => file cache (if FIELD_TYPE=file)
            [USER_FILE_SUFFIX]    => file extension suffix (if FIELD_TYPE=file)
            [USER_FILE_SIZE]      => file size (if FIELD_TYPE=[file|image])
            [FIELD_TYPE]          => answer type
            [FIELD_WIDTH]         => answer field width
            [FIELD_HEIGHT]        => answer field height
            [FIELD_PARAM]         => answer field parameter
          )
        [1] => array describing answer 2 
        [2] => array describing answer 3
        ...
        [N-1] => array describing answer N
      )
  [symbol identifier for question 2] => array describing answers to question 2 
  [symbol identifier for question  3] => array describing answers to question 3
  ...
  [symbol identifier for question N] => array describing answers to question N
)

Method parameters

Parameter Description
result_id Result ID.
field Array of symbol identifiers for questions and web form fields. These IDs must be retrieved.
result Link to the array of result fields, as well as some web form fields and status fields. This array structure:
Array
(
    [ID] => Result ID
    [TIMESTAMP_X] => date when result is modified 
    [DATE_CREATE] => date when result is created 
    [FORM_ID] => web form ID 
    [USER_ID] => ID of user who created the result (author)
    [USER_AUTH] => specifies if author is authorized when result is created [Y|N]
    [STAT_GUEST_ID] => ID of the visitor who created the result 
    [STAT_SESSION_ID] => ID of the session that contains the created result 
    [STATUS_ID] => ID of the status that contains the result 
    [STATUS_TITLE] => status title containing the result  
    [STATUS_DESCRIPTION] => status description containing the result 
    [STATUS_CSS] => name CSS class, containing the result  
    [SID] => symbol identifier for the web form 
    [NAME] => web form name 
    [IMAGE_ID] => ID of the web form image 
    [DESCRIPTION] => web form description 
    [DESCRIPTION_TYPE] => web form description type [text|html]
)
answer Link to the array, describing values of answers to questions or web from field values for the specified result_id. Structure of this array:
Array
(
  [symbol identifier of the question 1] => array describing the answers to question 1
    Array
    (
      [Answer ID 1] => array, describing the answer 1
        Array
        (
          [RESULT_ID]           => result ID
          [FIELD_ID]            => question ID
          [SID]                 => question symbol identifier
          [TITLE]               => question text
          [TITLE_TYPE]          => question text type [text|html]
          [FILTER_TITLE]        => filter field title
          [RESULTS_TABLE_TITLE] => column title of the results table 
          [ANSWER_ID]           => answer ID  
          [ANSWER_TEXT]         => answer parameter ANSWER_TEXT
          [ANSWER_VALUE]        => answer parameter ANSWER_VALUE
          [USER_TEXT]           => type text  
          [USER_DATE]           => input date (if FIELD_TYPE=date)
          [USER_FILE_ID]        => file ID (FIELD_TYPE=[file|image])
          [USER_FILE_NAME]      => file name
          [USER_FILE_IS_IMAGE]  => "Y" - FIELD_TYPE=image; "N" - FIELD_TYPE=file 
          [USER_FILE_HASH]      => file cache (if FIELD_TYPE=file)
          [USER_FILE_SUFFIX]    => suffix to the file extension (FIELD_TYPE=file)
          [USER_FILE_SIZE]      => file size (if FIELD_TYPE=[file|image])
          [FIELD_TYPE]          => answer type
          [FIELD_WIDTH]         => answer field width 
          [FIELD_HEIGHT]        => answer field height 
          [FIELD_PARAM]         => answer field parameter 
        )
      [answer ID 2] => array describing answer 2
      [answer ID 3] => array describing answer 3
      ...
      [answer ID N] => array describing answer N
    )
  [symbol identifier of question 2] => array describing answers to question 2
  [symbol identifier of question 3] => array describing answers to question 3
  ...
  [symbol identifier of question N] => array describing answers to question N
)

See Also

Examples of use

<?
$RESULT_ID = 189; // result ID

$arAnswer = CFormResult::GetDataByID(
	$RESULT_ID, 
	array("VS_INTEREST"),  // question "Which areas of expertise you are interested in?" 
	$arResult, 
	$arAnswer2);

// print the result fields 
echo "<pre>"; print_r($arResult); echo "</pre>";

// print the answer values 
echo "<pre>"; print_r($arAnswer); echo "</pre>";

// print answer values in another format  
echo "<pre>"; print_r($arAnswer2); echo "</pre>";
?>
<?
$RESULT_ID = 189; // result ID

// get data on all questions 
$arAnswer = CFormResult::GetDataByID(
	$RESULT_ID, 
	array(), 
	$arResult, 
	$arAnswer2);

// print the result fields 
echo "<pre>"; print_r($arResult); echo "</pre>";

// print answer values  
echo "<pre>"; print_r($arAnswer); echo "</pre>";

// print answer values in another format  
echo "<pre>"; print_r($arAnswer2); echo "</pre>";
?>


© «Bitrix24», 2001-2024
Up