The PHP program does:
• connection with i5_connect
• create user space list with i5_userspace_create
• open the new user space with i5_userspace_prepare
• write into the user space with i5_userspace_put
• read into the user space with i5_userspace_get
• close the user space with i5_userspace_close
<?php
$user = "user";
$pass = "pwd";
$connect = "power8";
$property = array (I5_OPTIONS_JOBNAME => "PHPDQ" );
$TraceLvl = 4;
$TraceFile = "CR/TRACEPHP2";
$Hdlcon = i5_connect($connect, $user, $pass, $property);
$property = array(
I5_INITSIZE=>10,
I5_DESCRIPTION=>"User space created by PHP",
I5_INIT_VALUE=>"A",
I5_AUTHORITY=>"*ALL",
I5_LIBNAME=>"QTEMP",
I5_NAME=>"USERSPACE"
);
$ret = i5_userspace_create($property);
if (!$ret) trigger_error("i5_userspace_create error : ".i5_errormsg(), E_USER_ERROR);
$description = array(
array(
"Name" => "P1",
"IO" => I5_INOUT,
"Type" => I5_TYPE_CHAR,
"Length" => 10,
"Count" => 5
),
array(
"Name" => "P2C",
"IO" => I5_INOUT,
"Type" => I5_TYPE_LONG,
"Length" => 4
),
array(
"Name" => "P2",
"IO" => I5_INOUT,
"Type" => I5_TYPE_CHAR,
"Length" => 1,
"Count" => 2
),
array(
"DSName" => "PS",
"Count" => 2,
"DSParm" => array(
array(
"Name" => "PS1",
"IO" => I5_INOUT,
"Type" => I5_TYPE_CHAR,
"Length" => 10
),
array(
"Name" => "PS2",
"IO" => I5_INOUT,
"Type" => I5_TYPE_CHAR,
"Length" => 10
),
array(
"Name" => "PS3",
"IO" => I5_INOUT,
"Type" => I5_TYPE_CHAR,
"Length" => 10
)
)
)
);
$UspcHdl = i5_userspace_prepare("qtemp/USERSPACE", $description);
if (is_bool($UspcHdl)) trigger_error("i5_userspace_prepare error : ".i5_errormsg(), E_USER_ERROR);
$Psparameter = array(
array(
"PS1" => "test1",
"PS2" => "test2",
"PS3" => "test3"
),
array(
"PS1" => "test3",
"PS2" => "test4",
"PS3" => "test5"
)
);
$parameter2 = Array(
"P1" => array(
"t1",
"t2",
"t3",
"t4",
"t5"
),
"P2C" => 2,
"P2" => array(
"a",
"b"
),
"PS" => $Psparameter
);
$ret = i5_userspace_put($UspcHdl, $parameter2);
if (!$ret) trigger_error("i5_userspace_put error : ".i5_errormsg(), E_USER_ERROR);
$parmOut2 = array(
"P1" => "P1",
"PS" => "PS"
);
$ret = i5_userspace_get($UspcHdl, $parmOut2);
if ($ret === false) {
printError(i5_error());
trigger_error("i5_userspace_get error : " . i5_errormsg(), E_USER_ERROR);
} else {
echo '<pre>P1 = ';
print_r($P1);
echo '<br/>';
echo 'PS = ';
print_r($PS);
echo '<br/>';
echo '$parmOut2[\'PS\'][0] = ';
print_r($parmOut2['PS'][0]);
echo '<br/>';
echo 'parmOut2 = ';
print_r($parmOut2);
echo '</pre>';
}
$ret = i5_userspace_close($UspcHdl);
if (!$ret) {
printError(i5_error());
trigger_error("i5_userspace_close error : " . i5_errormsg(), E_USER_ERROR);
}
?>