Please enable JavaScript to view this site.

The manual for the JobRouter developer

Navigation: System activities > Use of PHP API methods for the CSV export example > Export the csv file

Use subtables

Scroll Prev Top Next More

As a next step we want to export all rows of the subtable with the configured separator into this CSV file. For this we need the method executeMethodForSubtable, which executes a method of the own class for all rows of the subtable. The resolve methods are automatically switched to the subtable so the resolving of the parameters is now related to the subtable values and no longer to the values of the process table.

Using subtables

<?php

class csvSystemActivity extends AbstractSystemActivityAPI

{

...

    private $fieldDelimiter;

    private $csvFile;

    private $csvFilePointer;

 

    protected function exportCsv()

    {

        $this->debug('exportCsv start');

                 

        $this->loadGlobalSettings();

        $this->openCsvFile('w');

 

        $this->debug('exportCsv end');

    }

 

    protected function loadGlobalSettings()

    {

        $this->fieldDelimiter = $this->resolveInputParameter('fieldDelimiter');

    }

         

    protected function openCsvFile($mode)

    {

        $this->csvFile = $this->getTempPath() . DIRECTORY_SEPARATOR . 'test.csv';

        $this->debug('csvFile: '.$this->csvFile);

        $this->csvFilePointer = fopen($this->csvFile, $mode);

 

        $this->debug('executeMethodForSubtable for '. $this->getFixSubtableName());

        $this->executeMethodForSubtable('writeSubtableLineIntoFile', $this->getFixSubtableName());

    }

 

    protected function writeSubtableLineIntoFile()

    {

        $this->debug('writeSubtableLineIntoFile for '. $this->getFixSubtableName());

    }

}