original_string: protected function build_table_chunk(&$rows, &$columnsgroups) {
          global $DB;
          if (!$rows) {
              return;
          }
  
          foreach ($columnsgroups as $columnsgroup) {
              $fields = 'c.id';
              $from = '{feedback_completed} c';
              $params = [];
              foreach ($columnsgroup as $nr => $item) {
                  $fields .= ", v{$nr}.value AS val{$nr}";
                  $from .= " LEFT OUTER JOIN {feedback_value} v{$nr} " .
                      "ON v{$nr}.completed = c.id AND v{$nr}.item = :itemid{$nr}";
                  $params["itemid{$nr}"] = $item->id;
              }
              list($idsql, $idparams) = $DB->get_in_or_equal(array_keys($rows), SQL_PARAMS_NAMED);
              $sql = "SELECT $fields FROM $from WHERE c.id ".$idsql;
              $results = $DB->get_records_sql($sql, $params + $idparams);
              foreach ($results as $result) {
                  foreach ($result as $key => $value) {
                      $rows[$result->id]->{$key} = $value;
                  }
              }
          }
  
          foreach ($rows as $row) {
              if ($this->buildforexternal) {
                  $this->add_data_for_external($row);
              } else {
                  $this->add_data_keyed($this->format_row($row), $this->get_row_class($row));
              }
          }
      }
code: protected function build_table_chunk(&$rows, &$columnsgroups) {
          global $DB;
          if (!$rows) {
              return;
          }
  
          foreach ($columnsgroups as $columnsgroup) {
              $fields = 'c.id';
              $from = '{feedback_completed} c';
              $params = [];
              foreach ($columnsgroup as $nr => $item) {
                  $fields .= ", v{$nr}.value AS val{$nr}";
                  $from .= " LEFT OUTER JOIN {feedback_value} v{$nr} " .
                      "ON v{$nr}.completed = c.id AND v{$nr}.item = :itemid{$nr}";
                  $params["itemid{$nr}"] = $item->id;
              }
              list($idsql, $idparams) = $DB->get_in_or_equal(array_keys($rows), SQL_PARAMS_NAMED);
              $sql = "SELECT $fields FROM $from WHERE c.id ".$idsql;
              $results = $DB->get_records_sql($sql, $params + $idparams);
              foreach ($results as $result) {
                  foreach ($result as $key => $value) {
                      $rows[$result->id]->{$key} = $value;
                  }
              }
          }
  
          foreach ($rows as $row) {
              if ($this->buildforexternal) {
                  $this->add_data_for_external($row);
              } else {
                  $this->add_data_keyed($this->format_row($row), $this->get_row_class($row));
              }
          }
      }
code_tokens: protected function build_table_chunk ( & $ rows , & $ columnsgroups ) { global $ DB ; if ( ! $ rows ) { return ; } foreach ( $ columnsgroups as $ columnsgroup ) { $ fields = 'c.id' ; $ from = '{feedback_completed} c' ; $ params = [ ] ; foreach ( $ columnsgroup as $ nr => $ item ) { $ fields .= ", v{$nr}.value AS val{$nr}" ; $ from .= " LEFT OUTER JOIN {feedback_value} v{$nr} " . "ON v{$nr}.completed = c.id AND v{$nr}.item = :itemid{$nr}" ; $ params [ "itemid{$nr}" ] = $ item -> id ; } list ( $ idsql , $ idparams ) = $ DB -> get_in_or_equal ( array_keys ( $ rows ) , SQL_PARAMS_NAMED ) ; $ sql = "SELECT $fields FROM $from WHERE c.id " . $ idsql ; $ results = $ DB -> get_records_sql ( $ sql , $ params + $ idparams ) ; foreach ( $ results as $ result ) { foreach ( $ result as $ key => $ value ) { $ rows [ $ result -> id ] -> { $ key } = $ value ; } } } foreach ( $ rows as $ row ) { if ( $ this -> buildforexternal ) { $ this -> add_data_for_external ( $ row ) ; } else { $ this -> add_data_keyed ( $ this -> format_row ( $ row ) , $ this -> get_row_class ( $ row ) ) ; } } }
docstring: Retrieve additional columns. Database engine may have a limit on number of joins.
  
  @param array $rows Array of rows with already retrieved data, new values will be added to this array
  @param array $columnsgroups array of arrays of columns. Each element has up to self::TABLEJOINLIMIT items. This
  is easy to calculate but because we can call this method many times we calculate it once and pass by
  reference for performance reasons
docstring_tokens: Retrieve additional columns . Database engine may have a limit on number of joins .