Data structure program call

Demonstrating how to define data structure parameters in the toolkit

Focus: Improvement in 1.4.0+ for data structure integrity. If you need backward compatibility for the "flattened" data structure style, you can turn off dataStructureIntegrity.

In Zend Server 6, dataStructureIntegrity is true by default in toolkit.ini.

For this demo, the input parameters are created by this code:

$param[] = $ToolkitServiceObj->AddParameterChar('both', 1,'INCHARA', 'var1', 'Y');
$param[] = $ToolkitServiceObj->AddParameterChar('both', 1,'INCHARB', 'var2', 'Z');
$param[] = $ToolkitServiceObj->AddParameterPackDec('both', 7, 4, 'INDEC1', 'var3', '001.0001');
$param[] = $ToolkitServiceObj->AddParameterPackDec('both',12,2,'INDEC2', 'var4', '0000000003.04');

// Data structure subfields
$ds[] = $ToolkitServiceObj->AddParameterChar('both', 1, 'DSCHARA', 'ds1','A');
$ds[] = $ToolkitServiceObj->AddParameterChar('both', 1, 'DSCHARB', 'ds2','B');
$ds[] = $ToolkitServiceObj->AddParameterPackDec('both',7, 4, 'DSDEC1', 'ds3', '005.0007' );
$ds[] = $ToolkitServiceObj->AddParameterPackDec('both',12, 2, 'DSDEC1', 'ds4', '0000000006.08');

// add data structure as a param named InnerDataStructure
$param[] = $ToolkitServiceObj->AddDataStruct($ds, 'InnerDataStructure');


Let's run the program twice, with dataStructureIntegrity=true and false:

1. Output after using $ToolkitServiceObj->setOptions(array('dataStructureIntegrity' => true)):
array (
  'var1' => 'C',
  'var2' => 'D',
  'var3' => '321.1234',
  'var4' => '1234567890.12',
  'InnerDataStructure' => 
  array (
    'ds1' => 'E',
    'ds2' => 'F',
    'ds3' => '333.3330',
    'ds4' => '4444444444.44',
  ),
)
Notice that the InnerDataStructure DS hierarchy was maintained (good).


2. Output after using $ToolkitServiceObj->setOptions(array('dataStructureIntegrity' => false)):
array (
  'var1' => 'C',
  'var2' => 'D',
  'var3' => '321.1234',
  'var4' => '1234567890.12',
  'ds1' => 'E',
  'ds2' => 'F',
  'ds3' => '333.3330',
  'ds4' => '4444444444.44',
)
Notice that the InnerDataStructure was flattened so that all fields are on a single level (bad).


Please send comments on this demo to alan@alanseiden.com.