i5_private_connect
Create or get a private persistent connection to an AS/400 server.
This function acts like i5_pconnect with I5_OPTIONS_PRIVATE_CONNECTION option.
except that the connection ID is automatically managed by the function.
|
resource i5_private_connect |
(string server,
|
Parameters
|
server |
Name of the IBM i server to connect to, New ! Special keyword I5_SAME_JOB can be used when running PHP on IBM i. Connection is then established within the actual PHP server job. No additional job is cretated on the system. When running PHP on IBM i, set this parameter to an empty string to connect to the local system. When running PHP on Windows or Linux, server name or address is mandatory. Default port is 6077. This default port connects to the default standalone Easycom server, running in EASYCOM subsystem on the targer system. For Zend Server or Zend Core, default port is 6079. This value is configured un php.ini file, section [zend], entry "i5comm.Port=6079". It connects to the Easycom server running in Zend subsystem. To change port to connect to, add the port number at the end the server name or address, separated by a colon:
| |
|
user |
User name to use for connection. When option I5_OPTIONS_SSO is set, user and password parameters are not used.
| |
|
Password |
Password for the user name.
| |
|
options |
Connection options in an associative array. See below details about connection options. | |
|
|
Option |
Description |
|
|
I5_OPTIONS_SSO |
New ! Single Sign On. Connection is established using the user id signed on the end user station. Kerberos and EIM are used by Easycom to process identification. This option can only be used with PHP on IBM i. This option is not available with the free version of i5-Toolkit.
|
|
|
I5_OPTIONS_JOBNAME |
Set the name of the new job in EASYCOM subsystem. |
|
|
I5_OPTIONS_SQLNAMING |
Set the naming convention in SQL Statement to separate library and file names. "SYS" (default) to use slashes (/). "SQL" to use dots (.). |
|
|
I5_OPTIONS_DECIMALPOINT |
Set the character value to use as decimal point. |
|
|
I5_OPTIONS_LOCALCP |
Set the local code page used by PHP application. See comments bellow about Character Set & Code page. |
|
|
I5_OPTIONS_CODEPAGEFILE |
Change the character conversion rules by using an external conversion table. |
|
|
I5_OPTIONS_RMTCCSID |
Set the EBCDIC CCSID to use for data conversion. If Easycom client job on the i5 doesn’t have a CCSID, and if its default CCSID is not appropriated, .the application can choose the right EBCDIC CCSID. |
|
|
I5_OPTIONS_EACUNLOCK |
Password to unlock EASYCOM server, by calling EACP003 exit program. |
|
|
I5_OPTIONS_ALIAS |
Alias name given to the connection. This option has an effect only on when PHP server is running on Windows, in multi thread configuration. |
|
|
I5_OPTIONS_INITLIBL |
specifies library names to add on top of library list. |
|
|
I5_OPTIONS_IDLE_TIMEOUT |
Used on i5_pconnect() only. Set the delay (seconds) after what a persistent connection is closed if it not reused by a script. Default is infinite. |
|
|
I5_OPTIONS_PRIVATE_CONNECTION |
Used on i5_pconnect() only. Set the ID of the persistent connection to reuse. |
|
|
I5_OPTIONS_AUTOMATIC_NEXT_RESULT |
String value. For compatibility with previous Easycom versions, the first i5_fetch_xxx() fetches the parameters values, if this option is not set to "1". |
|
|
I5_OPTIONS_SSL_MODE |
Windows and Linux only ! I5_OPTIONS_SSL_TRUE/ I5_OPTIONS_SSL_FALSE/ I5_OPTIONS_SSL_MANDATORY Forces SSL mode. If true, the SSL connection will be attempted, and if SSL cannot be used, a non secure connection will be attempred. If mandatory, SSL connection will be attempted, and if SSL cannot be used, connection is aborted. |
|
|
I5_OPTIONS_SSL_INTF |
I5_SSL_INTERFACE_WINDOWS / I5_SSL_INTERFACE_OPENSSL |
|
|
I5_OPTIONS_SSL_CAFILE |
In OpenSSL, the CA file to verify server certificate. |
|
|
I5_OPTIONS_SSL_USER_CERT_FILE |
In OpenSSL, the CA path in which searching for authority certificates. This is to verify the server cerficicate. |
|
|
I5_OPTIONS_SSL_USER_CERT_FILE |
Client certificate file. This is for client certificate authentication, when OpenSSL is used. The certificate file must be in PEM format. When using Windows interface the option is not needed: the certificate is automatically selected. |
|
|
I5_OPTIONS_SSL_USER_CERT_PKEY_FILE |
Client certificate private key file. This is the file path for the OpenSSL private key file. When using Windows interface the option is not needed: the certificate and private key is automatically selected. |
|
|
I5_OPTIONS_SSL_USER_CERT_PASSPHRASE |
Passphrase to be able to read the private key file. This is used in OpenSSL only. |
Returns:
True if OK, false if failed.
|
I5_ERR_MEMALLOC |
3 |
Not enough memory |
|
I5_ERR_PHP_HDLCONN |
257 |
This resource has no connection active. |
|
I5_ERR_PHP_OPTIONSNUMBER |
260 |
Option number -1 is unknown. |
|
I5_ERR_PHP_NBPARAM_BAD |
263 |
Wrong parameter count |
|
I5_ERR_PGM_DONT_EXIST |
530 |
Internal error; please contact Aura Equipement; error number 530 |
This function acts like i5_connect(), except for the following differences :
- If a connection to the same AS/400 server, same user profile and password, already exists within the current PHP session, it will be reused.
- If such a connection doesn’t exist, a new one is created, kept open when the PHP script ends, and dedicated to the current PHP session.
- A subsequent call to i5_close() will not close the connection.
Use i5_pclose() to definitely close the connection.
- A time out can be set with option I5_OPTIONS_IDLE_TIMEOUT.
If the connection isn’t reused during that delay, it will be automatically closed.
- Easycom manages session affinity by creating private jobs for the PHP session. All the PHP scripts inside the same PHP session, use the same AS/400 job along the session.
Call function i5_get_property(), with option I5_NEW_CONNECTION , to know if the returned connection is a new one, or not.
Private connections, or, Connection affinity:
When a PHP script connect to a private i5 job, it gets a connection that will not be reused by any other PHP session.
The job environment is maintained along the PHP session. For example, If a script creates a file in QTEMP library, this file will be present for subsequent scripts in the same session.
Resources and cursors are not maintained !
I5_private_connect() uses same option as i5_pconnect().
Following special options apply only to i5_pconnect() and i5_private_connect().
I5_OPTIONS_IDLE_TIMEOUT:
Set the maximum delay (in seconds) the AS/400 job will remain active without any request from PHP.
Default delay is 900 seconds.
If the PHP session ends without running i5_pclose(), the job will end after this delay.
I5_OPTIONS_PRIVATE_CONNECTION:
Setting value 0 to this option will force Easycom to create a new private connection, even if one already exist.
Example 1: Connecting to a private job.
<?php
session_start();
$action = 'noAction';
if (isset($_GET['typeAction'])){
$action = $_GET['typeAction'];
}
?>
<html>
<head>
<title>Easycom For php</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
Action : <?php echo $action ?>
<body bgcolor="#FFFFFF" >
<p><b><font size="5">Sample</font></b></p>
<?php
$option = array();
// I5_OPTIONS_IDLE_TIMEOUT After a delay with no activity, the job will end.
$option[I5_OPTIONS_IDLE_TIMEOUT] = "50";
$retcon = i5_private_connect($connect, $user, $pass, $option);
if (is_bool($retcon) && $retcon == FALSE){
$errorTab = i5_error();
print_r($errorTab);
} else {
$isnew = i5_get_property(I5_NEW_CONNECTION, $retcon);
if ($isnew) {
/* New connection. Do some job initialization */;
} else {
/* Connection was already existing. Using the same job */;
}
}
if ($action == 'pclose'){
$ret = i5_pclose();
echo "Connection definitely closed<BR>";
}
?>
<div style="border:solid">
Close definitely the connection :.
<form action="privateConnectId.php" method="get">
<input name="typeAction" type="hidden" value="pclose">
<input name="validate" type="submit" value="Close Connection">
</form>
</div>
<br>
<div style="border:solid">
Continue with the same connection :.
<form action="privateConnectId.php" method="get">
<input name="typeAction" type="hidden" value="noAction">
<input name="validate" type="submit" value="Re Use">
</form>
</div>
</body>
</html>