TIP: You can share same connection between PHP Toolkit and regular ibm_db2 used ofr other purposes in your script, therefore your PHP script can use both raw XML (example above) and Toolkit (Alan) in the same PHP script. BTW -- If you have a DB2/ODBC driver on your laptop (Windows/Linux/Mac), you could call these stored procedures 2-tier using any language on your laptop PHP, Ruby, perl, .net, Java, whatever.
- Code: Select all
// share my ibm_db2 connection either persistent or full open/close
if ($i5persistentconnect) $conn = db2_pconnect($database,$user,$password);
else $conn = db2_connect($database,$user,$password);
// route location to same job on IBM i, known as IPC or internalKey (also known as state full)
// if IPC missing you just use temp job with no recall of xmlservice when script ends (stateless)
$internalKey = '/tmp/packers';
// toolkit calling same job as regular old ibm_db2
try { $ToolkitServiceObj = ToolkitService::getInstance($conn); } catch (Exception $e) { die($e->getMessage()); }
$ToolkitServiceObj->setToolkitServiceParams(array('InternalKey'=>$internalKey, 'plug'=>"iPLUG32K"));
// reuse connection call from ibm_db2 (same code stuff inside Toolkit)
$stmt = db2_prepare($conn, "call $libxmlservice.iPLUG65K(?,?,?,?)");
$ipc = $internalKey; // same job as Toolkit above
$ctl = '*sbmjob';
$clobIn = getxml();
$clobOut = "";
$ret=db2_bind_param($stmt, 1, "ipc", DB2_PARAM_IN);
$ret=db2_bind_param($stmt, 2, "ctl", DB2_PARAM_IN);
$ret=db2_bind_param($stmt, 3, "clobIn", DB2_PARAM_IN);
$ret=db2_bind_param($stmt, 4, "clobOut", DB2_PARAM_OUT);
$ret=db2_execute($stmt);
// reuse the same DB2 connection for a query
$result = db2_exec($conn,"select * from animals");

