i5_get_property in i5_toolkit

[adrotate group=”4,3″]
I was trying out the PRIVATE connection capabilities of the i5_toolkit and came across a couple of problems. The first problem was the Zend Studio IDE reports the function as undefined, I did look through the headers quickly and could not find any definitions for the function. Yet when the script ran it did actually produce some results which were also confusing based on the samples and information supplied in the documentation.

This is the sample I was working with from the manuals.


<?php
/* Private connection to i5/OS */
conId = 0;
if (isset($_SESSION['connectionID']))
{
 $conId = $_SESSION['connectionID'];
 echo "Connection ID is $conId
"; } else { echo "No connection ID stored.
"; } // I5_OPTIONS_PRIVATE_CONNECTION connection is private for the session // I5_OPTIONS_IDLE_TIMEOUT After a delay with no activity, the job will end. $retcon = i5_pconnect ('SYSTEMI', "USER", "pwd", array( I5_OPTIONS_PRIVATE_CONNECTION => $conId, I5_OPTIONS_IDLE_TIMEOUT=>"60")); if (is_bool($retcon) && $retcon == FALSE) { $errorTab = i5_error(); if ($errorTab['cat'] == 6 && $errorTab['num'] == -12){ echo "Connection ID no longer active
"; $_SESSION['connectionID'] = 0; } else print_r($errorTab); } else { if ($conId == 0) { //Session varaible was 0: Get connection ID and store it in session variable. $ret = i5_get_property(I5_PRIVATE_CONNECTION, $retcon); if (is_bool($ret) && $ret == FALSE) { $errorTab = i5_error(); print_r($errorTab); } else { // Connection ID is stored in session variable $_SESSION['connectionID'] = $ret; } } } ?>

The code has a couple of coding errors but the area which concerned me is the function call to i5_get_property() as this is where I should be able to determine if a new session had been started or not.
The Studio reported the function as undefined, which while not a real problem (its the IDE that thinks its undefined) needs to be fixed.

When this code was changed to run on our system with some slight modifications such as the user name, password and server it came back with the following output when the session ID was invalid.

Array ( [0] => 285 [1] => 9 [2] => the 2576 connection has not been found. [3] => [num] => 285 [cat] => 9 [msg] => the 2576 connection has not been found. [desc] => )

This is a fairly simple issue because we noticed that the cat value was 9 and the num value was 285 not 6 and -12 as in the sample code. So we fixed up the code to be if ($errorTab['cat'] == 9 && $errorTab['num'] == 285) and moved on.

This is the information about the i5_get_property() function directly from the i5_toolkit help.

i5_get_property
int/string i5_get_property(int Property, [resource connection]).
Description: Gets a connection status for a connection opened either by i5_pconnect () or i5_connect ()
Return Values:
– 0 : The connection to i5/OS was already opened by the previous PHP script via i5_pconnect().
– 1 : New connection which was not used by another PHP script.
Arguments:
Property – I5_NEW_CONNECTION
connection – Result of i5_pconnect or i5_connect ()
Example:
$isnew = i5_get_property(I5_NEW_CONNECTION, $conn);

This is stating the function should only return 1 or 0. Our tests seemed to always fail tests for these values so we decided to add an echo state,ent to the code to find out exactly what was being returned. It turns out that the function returns the job number of the connection which was created in the case of the above output 2576 (it is ltrim’d of the ‘0’s) which can be confirmed by the returned string the “2576 connection has not been found”. This again is not a real issue as a bit of coding showed us what we should really be testing for, but the samples and code provided with the toolkit have some deficiencies where function descriptions are concerned.

We have also contacted the i5_toolkit developers EASYCOM-AURA for more information on exactly what error codes can be returned from the various functions so we can better react to issues when they occur. As soon as they provide that information or a link I will post as a comment to this post.

We have a number of severe issue with the Zend Server and IBM ‘i’ which we are asking Zend and IBM to look at as we are unsure exactly why the problems are occurring. If we find out any information we will post the results. At the moment we have one server unable to run the webservers at all due to major issues such as taking up 100% of the CPU and causing other processes to end abnormally, this would be quite troubling if these were production systems. Hopefully we can get to the bottom of why?

Chris…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.