API Reference Guide > PHP XMLSERVICE Toolkit > Compatibility Wrapper > PHP Toolkit for IBM i > PHP Toolkit Functions

PHP Toolkit Functions

All PHP Toolkit functions start with prefix "i5".

Connection Management

i5_connect

Implemented in Compatibility Wrapper.

resource i5_connect(string server, string user, string password[, array options]).

Example:

$conn i5_connect("1.2.3.4""MYUSER""MYPWD");

if (!
$conn) {

  die(i5_errormsg());

}

Connection Options:

I5_OPTIONS_JOBNAME - job name (machine name by default)

I5_OPTIONS_SQLNAMING - Enables using dotted (.) or slashed (/) notation in SQL requests

I5_OPTIONS_DECIMALPOINT - Enables using dot or comma as decimal separator

I5_OPTIONS_CODEPAGEFILE - Enables using specific code page (CCSID)

I5_OPTIONS_ALIAS - Enables naming a connection. If the name is used in another i5_connect, then the other i5_connect will use the same connection.

I5_OPTIONS_INITLIBL - Specified libraries are added to the beginning of the initial library list.

I5_OPTIONS_LOCALCP - Sets the local code page used by PHP application.

I5_OPTIONS_RMTCCSID - Sets the EBCDIC CCSID

Note:

The I5_OPTIONS_JOBNAME option is not implemented in Compatibility Wrapper for the i5_connect function. This function uses a stateless connection, rather than submitting a job. If I5_OPTIONS_JOBNAME is required,please use i5_pconnect.

 

i5_pconnect

Implemented in Compatibility Wrapper.

resource i5_pconnect(string server, string user, string password[, array options]).

Example - Basic Connection

/* Basic connection to i5/OS */

$conn = i5_pconnect("i.2.3.4","USER","PWD", array(i5_OPTIONS_IDLE_TIMEOUT=>120))

    or die(i5_errormsg());

echo " Connection OK <BR>";

 

 

/* Connection error detail in case of failure */

$conn = i5_pconnect("i.2.3.4","MYUSER","MYPWD");

if (!$conn) {

$error = i5_error();

echo " Error during connection\n";

echo "<BR> Error number: ".$error["num"];

echo "<BR> Error category: ".$error["cat"];

echo "<BR> Error message: ".$ error ["msg"];

echo "<BR> Error description: ".$ error ["desc"];

trigger_error("I5 persistent connection fails", E_USER_ERROR);

}

else {

echo " Connection OK ";

$isnew = i5_get_property(I5_NEW_CONNECTION);

if ($isnew) ) {

echo " New connection. Do some job initialization \n";

}

}

 

 

/* leaves connection without closing it. */

/* Make it available for another script. */

$ret = i5_close($conn);

if($ret){

echo " I5 disconnected";

}

else

{

$ret = i5_errormsg($conn);

}

Example - Private Connection

<?php

/* Private connection to i5/OS */

conId = 0;

if (isset($_SESSION['connectionID']))

{

 $conId = $_SESSION['connectionID'];

 echo "Connection ID is $conId<BR>";

}

else

{

 echo "No connection ID stored.<BR>";

}

// 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<BR>";

  $_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;

  }

 }

}

?>

Connection Options:

 

i5_pclose

Implemented in Compatibility Wrapper.

bool i5_close([resource connection]).

Example:

/* Basic connection to i5/OS */

$conn = i5_pconnect("("i.2.3.4","USER","PWD")

if ($conn) {

   echo "Connection succeeds <BR>";

   [treatments...]

 

   $closing = i5_pclose($conn);

   

   if ($closing) {

     echo "Disconnection succeeds";

     }

   }

i5_get_property

Implemented in Compatibility Wrapper.

int/string i5_get_property(int Property, [resource connection]).

Example:

$isnew = i5_get_property(I5_NEW_CONNECTION, $conn);

i5_close

Implemented in Compatibility Wrapper.

bool i5_close([resource connection]).

i5_adopt_authority

Implemented in Compatibility Wrapper.

bool i5_adopt_authority(string username, string password, [resource connection]).

i5_error

Implemented in Compatibility Wrapper.

bool i5_error([resource connection]).

i5_errormsg

Implemented in Compatibility Wrapper.

string i5_errormsg([resource connection]).

i5_errno

Implemented in Compatibility Wrapper.

int i5_errno([resource connection]).

i5_version

Compatibility Wrapper only.

string i5_version().

i5_output

Compatibility Wrapper only.

array i5_output().

Example:

$prog = i5_program_prepare("DEMOPGM");

if(i5_program_call($prog, array(1,2,"abc"))) {

if (function_exists('i5_output')) extract(i5_output());

$result = i5_fetch_assoc($prog);

print "result is $result['retval']<br>";

} else {

print "Program call failed.<br>";

}

Back to Top

CL Calls

i5_command

Implemented in Compatibility Wrapper.

bool i5_command(string command[, array inputs, array outputs, resource connection]).

Note: The input parameter is required if the output parameter is specified.

Note:

If i5_command() is used in a function, remember Compatibility Wrapper requires the use of i5_output() to extract the output.

Example:

i5_command("rtvjoba", array(), array("curlib" => "curl",.

"user"=>"user",.

"usrlibl" => "userlib",.

"syslibl" => array("syslib", "char(165)"), .

).

);.

print "User : $user<br>" ;.

print "User library : $userlib<br>" ;.

print "System libs list : $syslib<br>" ;.

print "Current library : $curl<br>" ;.

Back to Top

Program Calls

i5_program_prepare

Implemented in Compatibility Wrapper.

resource i5_program_prepare(string name[, array description][, resource connection]).

i5_program_prepare_PCML

Implemented in Compatibility Wrapper.

resource i5_program_prepare_PCML (array description[, resource connection]).

The program information file (in PCML format) can be created by compiling the RPG program.

Example:

CRTBNDRPG PGM(EACDEMO/TESTSTRUC)  SRCFILE(EACDEMO/QRPGLESRC) SRCMBR(TESTSTRUC)  PGMINFO(*PCML) INFOSTMF('/www/zendSvr/htdocs/teststruc.pcml')

The PCML file will contain the program parameters info. There are two ways you can assign the program parameters to i5-program_prepare_PCML description:

Copy the content of PCML file to you PHP script and assign the i5_program_prepare_PCML description array to the PCML content. See PCML Example 1 (below).

Assign i5_program_prepare description array to the PCML file located in the same PHP program directory. See PCML Example 2 (below.

PCML Example 1:

$description = "<pcml version=\"4.0\">

   <!-- RPG module: TESTSTRUC  -->

   <!-- created: 2006-10-12-11.46.56 -->

   <!-- source: EACDEMO/QRPGLESRC(TESTSTRUC) -->

   <!-- 5 -->

   <struct name=\"S2\">

      <data name=\"ZOND2\" type=\"zoned\" length=\"10\" precision=\"5\" usage=\"inherit\" />  

      <data name=\"PACK2\" type=\"packed\" length=\"19\" precision=\"5\" usage=\"inherit\" />

      <data name=\"PACK3\" type=\"packed\" length=\"19\" precision=\"5\" usage=\"inherit\" />

      <data name=\"ALPH2\" type=\"char\" length=\"20\" usage=\"inherit\" />

   </struct>

   <!-- 1 -->   

   <struct name=\"S1\">

      <data name=\"ZOND\" type=\"zoned\" length=\"10\" precision=\"5\" usage=\"inherit\" />   

      <data name=\"PACK1\" type=\"packed\" length=\"19\" precision=\"5\" usage=\"inherit\" />

      <data name=\"ALPH1\" type=\"char\" length=\"10\" usage=\"inherit\" />

   </struct>

   <program name=\"TESTSTRUC\" path=\"/QSYS.LIB/EACDEMO.LIB/TESTSTRUC.PGM\">   

      <data name=\"CODE\" type=\"char\" length=\"10\" usage=\"output\" />

      <data name=\"S1\" type=\"struct\" struct=\"S1\" usage=\"inputoutput\" />

      <data name=\"S2\" type=\"struct\" struct=\"S2\" usage=\"inputoutput\" />

      <data name=\"PACK\" type=\"packed\" length=\"1\" precision=\"1\"

      usage=\"output\" />   

      <data name=\"CH10\" type=\"char\" length=\"19\" usage=\"output\" />

      <data name=\"CH11\" type=\"char\" length=\"20\" usage=\"output\" />

      <data name=\"CH12\" type=\"char\" length=\"29\" usage=\"output\" />

      <data name=\"CH13\" type=\"char\" length=\"33\" usage=\"output\" />

   </program>

</pcml>

   ";

PCML Example 2:

($description = file_get_contents("/www/zendSvr/htdocs/teststruc.pcml"))

or trigger_error("Error while opening PCML file", E_USER_ERROR);

i5_program_call

Implemented in Compatibility Wrapper.

bool i5_program_call(resource program, array params[, array retvals]).

Note:

If i5_program_call() is used in a function, remember Compatibility Wrapper requires the use of i5_output() to extract the output.

Example:

$prog = i5_program_prepare("DEMOPGM");.

if(i5_program_call($prog, array(1,2,"abc"))) {.

$result = i5_fetch_assoc($prog);.

print "result is $result['retval']<br>";.

} else {.

print "Program call failed.<br>";.

}.

Note:

Use i5_COMMAND in order to invoke a program without parameters. For example, i5_command("call LIB_NAME/PROGRAM_NAME").

i5_program_close

Implemented in Compatibility Wrapper.

void i5_program_close(resource program).

    Back to Top

Data Retrieval

i5_fetch_array

Not implemented in Compatibility Wrapper.

 array i5_fetch_array(resource result [, int option ] ).

 array i5_fetch_assoc(resource result [, int option ] ).

 object i5_fetch_object(resource result [, int option ] ).

 array i5_fetch_row(resource result [, int option] ).

i5_info

Not implemented in Compatibility Wrapper.

array i5_info ( resource result [, int/string field ] ).

i5_field_len

Not implemented in Compatibility Wrapper.

int i5_field_len ( resource result, int/string field ).

i5_field_name

Not implemented in Compatibility Wrapper.

int i5_field_name ( resource result, int field ).

i5_field_scale

Not implemented in Compatibility Wrapper.

int i5_field_scale ( resource result, int/string field ).

i5_field_type

Not implemented in Compatibility Wrapper.

string i5_field_type ( resource result , int/string field ).

i5_list_fields

Not implemented in Compatibility Wrapper.

array i5_list_fields ( resource result ).

i5_num_fields

Not implemented in Compatibility Wrapper.

int i5_num_fields ( resource result ).

i5_result

Not implemented in Compatibility Wrapper.

mixed i5_result ( resource result, int/string field]).

  Back to Top

Native File Access

i5_open

Not implemented in Compatibility Wrapper.

resource i5_open (string fileName [, int mode ][,resource connection]).

Note:

OPEN_READ or I5_OPEN_READWRITE modes are required to be combine with other modes. For example, $ret = i5_open ("LIB/FILE", I5_OPEN_READWRITE | I5_OPEN_EXCL);

i5_addnew

Not implemented in Compatibility Wrapper.

bool i5_addnew ( resource file [, int mode] ).

i5_edit

Not implemented in Compatibility Wrapper.

bool i5_edit ( resource file [, int mode] ).

i5_delete

Not implemented in Compatibility Wrapper.

bool i5_delete ( resource file ).

i5_setvalue

Not implemented in Compatibility Wrapper.

bool i5_setvalue (resource file, int/string field, mixed value).

bool i5_setvalue (resource file, array values ).

i5_update

Not implemented in Compatibility Wrapper.

bool i5_update ( resource file ).

i5_range_from

Not implemented in Compatibility Wrapper.

bool i5_range_from ( resource file,bool included,array values).

i5_range_to

Not implemented in Compatibility Wrapper.

bool i5_range_to (resource result,bool included, array values ).

i5_range_clear

Not implemented in Compatibility Wrapper.

bool i5_range_clear (resource file).

i5_data_seek

Not implemented in Compatibility Wrapper.

bool i5_data_seek (resource result, int record_number).

i5_seek

Not implemented in Compatibility Wrapper.

bool i5_seek (resource file, int/string operator, array keyValue).

i5_bookmark

Not implemented in Compatibility Wrapper.

int i5_bookmark (resource file).

i5_free_file

Not implemented in Compatibility Wrapper.

bool i5_free_file (resource file).

i5_new_record

Not implemented in Compatibility Wrapper.

bool i5_new_record (resource file, array data).

i5_update_record

Not implemented in Compatibility Wrapper.

bool i5_update_record (resource file, array data).

Example:

$file = i5_open("API/TESTFILE", I5_OPEN_READWRITE);.

$rec = i5_fetch_row($file, I5_READ_FIRST);.

i5_update_record($file,  array("CODE" => "C-02", "NOM" => "DUPONT", "TYPE" => 3));.

i5_new_record($file, array('C-105', 'DUPOND', 'Jean', 'Avenue du Qubec', 'Les Ulis', 3, 'FR'));.

i5_delete_record

Not implemented in Compatibility Wrapper.

bool i5_delete_record(resource file).

Example:

$file = i5_open("API/TESTFILE", I5_OPEN_READWRITE);.

i5_new_record($file, array('C-105', 'DUPOND', 'Jean', 'Avenue du Qubec', 'Les Ulis', 3, 'FR'));.

$rec = i5_fetch_row($file, I5_READ_FIRST);.

i5_update_record($file,  array("CODE" => "C-02", "NOM" => "DUPONT", "TYPE" => 3));.

i5_delete_record($file);

i5_get_keys

Not implemented in Compatibility Wrapper.

array i5_get_keys(resource file).

  Back to Top

SQL File Access

i5_query

Not implemented in Compatibility Wrapper.

resource i5_query ( string query [, resource connection] )

Note:

i5_query function is suitable for SQL requests without parameters. If you plan to issue the same SQL statement with different parameters, consider using i5_prepare() and i5_execute().

Example:

$query = i5_query("SELECT * FROM EACDEMO/SP_CUST");

if(!$query) {

    echo "Error code: " . i5_errno()."

";

    echo "Error message: " . i5_errormsg()."

";

}

else {

/* Read records and display */

    echo "<table border=1>";

    $i = 0;

    while ($values = i5_fetch_row($query, I5_READ_NEXT) AND ($i < 10)) {

        $i++;

    echo "<tr>";

    echo "<td>" .$values[0]. "</td>";

    echo "<td>" .$values[1]. "</td>";

    echo "<td>" .$values[2]. "</td>";

    echo "<td>" .$values[3]. "</td>";

    echo "<td>" .$values[4]. "</td>";

    echo "<td>" .$values[5]. "</td>";

    echo "</tr>";

    }

    echo "</table>";

}

i5_free_query($query);

i5_prepare

Not implemented in Compatibility Wrapper.

resource i5_prepare ( string query [, resource connection] )

i5_bind_result

Not implemented in Compatibility Wrapper.

bool i5_bind_result ( resource result/query, mixed &var1 [,mixed &var2 ...] )

-Or-

bool i5_bind_result ( resource result/query, mixed &var, string namefield )

i5_execute

Not implemented in Compatibility Wrapper.

bool i5_execute ( resource stmt [,params] )

Example:

$town = "Paris";

/* Prepare a request */

$req = i5_prepare("SELECT area FROM cities WHERE Name=?");

if ($req) {

    /* Associate SQL variables */

    i5__bind_param($req, $town);  

    /* Execute the request */

    i5_execute($req);

    /* Associate the results variables */

    i5_bind_result($req, $region);

    /* Read records */

    i5_fetch_row($req);

    printf("%s is in area %s\n", $town, $region);

 

i5_getblob

Not implemented in Compatibility Wrapper.

string i5_getblob( resource result, int position )

-Or-

string i5_getblob( resource result, string namefield )

Note:

Reading and writing a blob requires a transaction.

Example:

/* Specify isolation level UR (COMMIT(*CHG)) */

i5_query( "SET TRANSACTION ISOLATION LEVEL UR" );

/* One of the select filed is a  blob column. */

$sql = "SELECT FLD1,  FLD2,  BLOB_COLUMN  FROM BLOB_TABLE";

$res = i5_query($sql);

$line = i5_fetch_row($res, I5_READ_NEXT);

/* element $line[2] contains blob ID */

$blob_data = i5_getblob($res, 2);

/* now the blob can be displayed or processed */

 

i5_setblob

Not implemented in Compatibility Wrapper.

bool i5_setblob ( resource stmt, int position, string blob )

Note:

Writing a blob requires a transaction.

Example:

/* Writing jpeg file content in blob */

$sql = "INSERT INTO CONTACTS (NAME, PRENOM, PHOTO) VALUES

(?,?,?)";

$req_prepa = i5_prepare($sql);

if ($req_prepa) {

  $name = "DUPONT";

  $prenom = "HENRY";

  $file_image = fopen("hdupont.jpg", 'r');

  $photo = fread($file_image, filesize($file_image));

  $ret0 = i5_setparam($req_prepa, 0, $name);

  $ret1 = i5_setparam($req_prepa, 1, $prenom);

  $ret2 = i5_setblob($req_prepa, 2, $photo);

  $ret = i5_execute($req_prepa);

  if ($ret) {echo "Blob writing successful.\n";}

  }

i5_bind_param

Not implemented in Compatibility Wrapper.

bool i5_bind_param ( resource stmt, mixed &var1 [, mixed &var2…])

Example:

$conn = i5_connect("MY_i5", "USER", "PASSWORD");

if ($conn) {

   $sql = "SELECT * FROM EACDEMO/SP_CUST WHERE CUST_ID >

      ? FOR FETCH ONLY";

   $stmt = i5_prepare($sql);

 

    $lower_limit=1000;

     $ret = i5_bind_param( $stmt, &$lower_limit );  

    $result = i5_execute($stm);

   if (!$result) {

           echo 'The SQL execute failed ';

           echo 'SQLSTATE value: ' .  i5_errno();

           echo ' Message: ' . i5_errormsg();

        }

        else

        {        

           //read records using i5_fetch_row(($stmt, I5_READ_NEXT )

         }       

}

i5_setparam

Not implemented in Compatibility Wrapper.

bool i5_setparam ( resource stmt, int position, mixed value)

Note:

Request must be prepared with i5_prepare function.

Example 1:

$insert = 'INSERT INTO my_library/animals (id, race, name, weight)   

 VALUES (?, ?, ?, ?)';

 $req = i5_prepare($insert); $animals = array(1, 'cat',  'Mistinguette', 3.2); if ($req) {

 $result = i5_execute($req, $animals);

 if ($result) {

print "Mistinguette adding successful.<br>";

}

i5_setparam($req, 2, "Hercule");

i5_setparam($req, 3, 3.8);

$result = i5_execute($req);

if ($result) {

print "Hercule adding successful.<br>";

}

Example 2 - Calling stored procedures with IN parameter
The stored procedure in the following example accepts one parameter:

    1. Create table

    2. An input (IN) parameter that accepts the name of the first animal as input

    3. An input-output (INOUT) parameter that accepts the name of the second animal as input and returns the string TRUE if an animal in the database matches that name

    4. An output (OUT) parameter that returns the sum of the weight of the two identified animals

In addition, the stored procedure returns a result set consisting of the animals listed in alphabetic order starting at the animal corresponding to the input value of the first parameter and ending at the animal corresponding to the input value of the second parameter.

<?php

//

//CREATE TABLE SQL_LIB/TEST2 (A DATE NOT NULL WITH DEFAULT)

//

//

//create procedure SQL_LIB/test_a1(in parm1 date)    

//language SQL                                      

//begin                                                                                         

//                                                  

//set transaction isolation level UR;               

//insert into SQL_LIB/TEST2 values(parm1) ;       

//commit;                                           

//end;                                              

$user     = 'USER';

$password = 'PASS';

$conn_resource = i5_connect('127.0.0.1',$user,$password );

echo "Begin <br>";

if (!$conn_resource) {

echo  i5_errormsg();

exit();

 

}

$sql = "CALL SQL_LIB/TEST_A1(?)";

$stmt= i5_prepare($sql);

$val = '2007-05-22';

$ret = i5_paramdesc($stmt, I5_TYPE_CHAR, 0, 10, 0, I5_INOUT);

$ret = i5_setparam($stmt, 0, $val);

$result = i5_execute($stmt );

if($result === false){

echo "Execute Error:". i5_errno()."  Msg:".i5_errormsg()."<br>";

 

//echo $err;

}

else {

"<br>executed";

}

echo "<br>end";

?>

i5_paramdesc

Not implemented in Compatibility Wrapper.

bool i5_paramdesc(resource result, int ASType, int sequence, int length, int decimals, int usage).

Example:

$storedProcedure = "CALL LIBRARY/PROGRAM(?,?)";

$result =i5_prepare($storedProcedure);

if(!$result)

{

echo("Prepare failed");

exit();

}            

// Describe first parameter

$ret = i5_paramdesc($result, I5_TYPE_CHAR, 0, 10, 0, I5_IN);

$val = "ZENDCORE";

$ret = i5_setparam($result, 0, $val);

if(!$ret)

{

echo("Set Param failed");

exit();

}            

// Describe second parameter

$ret = i5_paramdesc($result, I5_TYPE_CHAR, 1, 10, 0, I5_INOUT);

$val2 = " ";

$ret = i5_setparam($result, 1, $val2);

if(!$ret)

{

echo("Set Param failed");

exit();

}   

$hdl = i5_execute($result);

i5_free_query

Not implemented in Compatibility Wrapper.

bool i5_free_query ( resource query )

  Back to Top

Transactions

i5_transaction

Not implemented in Compatibility Wrapper.

bool i5_transaction (  int mode [, resource connection] )

Example:

<?php

$conn = i5_connect("MY_i5", "USER", "PASSWORD");

if ($conn) {

    $res = i5_query("SELECT count(*) FROM animals");

    $rec = i5_fetch_array($res );

    echo $rec[0] . "\n";

    

       /* Start a transaction */

    i5_transaction(I5_ISOLEVEL_NONE, $conn);

   

    /* Add records to ANIMALS table */

    i5_query("INSERT INTO animals VALUE 'Cat', 'Mistigri'");

    

    $res = i5_query("SELECT count(*) FROM animals");

    $rec = i5_fetch_array($res);

    echo $res[0] . "\n";

i5_commit

Not implemented in Compatibility Wrapper.

bool i5_commit( [string comment] [resource connection])

Example:

$conn = i5_connect("MY_i5", "USER", "PASSWORD");

if ($conn) {

    $res = i5_query("SELECT count(*) FROM animals");

    $rec = i5_fetch_array($res );

    echo $rec[0] . "\n";

    

    /* Start a transaction */

    i5_transaction(I5_ISOLEVEL_NONE);

   

    /* Insert records to ANIMALS table*/

    i5_query("INSERT INTO Animals VALUES ('CAT', 'Misstic', 'F', 3.2)");

    i5_query("INSERT INTO Language VALUES ('DOG', 'Hercule', 'M', 4.4)");

    

    $res = i5_query("SELECT count(*) FROM animals");

    $rec = i5_fetch_array($res);

    echo $rec[0] . "\n";

    

    /* Commit the changes */

    i5_commit($conn);

    

    $res = i5_query("SELECT count(*) FROM animals");

    $rec = i5_fetch_array($res);

    echo $rec[0] . "\n";

    i5_close($conn);

    }

i5_rollback

Not implemented in Compatibility Wrapper.

bool i5_rollback ( [resource connection] )

Example:

<?php

$conn = i5_connect("127.0.0.1", "USER", "PASSWORD");

if ($conn) {

    /* Start a transaction*/

    $tran = i5_transaction(I5_ISOLEVEL_CHG);

        $res = i5_query("SELECT count(*) FROM my_library/animals");

    $rec = i5_fetch_array($res );

    echo $rec[0] . "

\n";

    

    /* Delete all records from the ANIMALS table */

    $res = i5_query("DELETE FROM my_library/animals");

    $res = i5_query("SELECT count(*) FROM my_library/animals");

    $err = i5_error();

    $rec = i5_fetch_array($res);

    echo $rec[0] . "

\n";

    

    /* Cancel the DELETE operation */

    i5_rollback($conn);

    $res = i5_query("SELECT count(*) FROM my_library/animals");

    $rec = i5_fetch_array($res);

    echo $rec[0] . "

\n";

    i5_close($conn);

}

?>

  Back to Top

Data Queues

i5_dtaq_prepare

Implemented in Compatibility Wrapper.

resource i5_dtaq_prepare(string name, array description [,int key][,resource connection])

i5_dtaq_receive

Implemented in Compatibility Wrapper.

mixed i5_dtaq_receive(resource queue[, string/int operator, string key][, int timeout])

i5_dtaq_send

Implemented in Compatibility Wrapper.

bool i5_dtaq_send(resource queue, string key, mixed data)

The data should conform to the description format, and can be either in flat array or key->value pair array.

i5_dtaq_close

Implemented in Compatibility Wrapper.

bool i5_dtaq_close(resource queue)

Example 1:

<?php

$description = array("Name"=>"DATA", "Type"=>I5_TYPE_CHAR, "Length"=>50);

$dtaqHdl_KEY = i5_dtaq_prepare("EACDEMO/DTAQ_KEY", $description, 5);

$ret = i5_dtaq_send($dtaqHdl_KEY, "mykey", "the dataqueue test data");

var_dump($ret);

if(!$ret) var_dump(i5_error());

$ret = i5_dtaq_receive($dtaqHdl_KEY, "EQ", "mykey");

var_dump($ret);

?>

Example 2:

<?php

$descriptionC = array("DSName"=>"PS", "DSParm"=>array(

array("Name"=>"PS1", "Type"=>I5_TYPE_CHAR, "Length"=>"10"),

array("Name"=>"PS2", "Type"=>I5_TYPE_PACKED, "Length"=>"10.4"),

array("Name"=>"PS3", "Type"=>I5_TYPE_CHAR, "Length"=>"10")

)

);

$dtaqHdl_KEY = i5_dtaq_prepare("EACDEMO/DTAQ_KEY", $descriptionC, 10);

$parameter = array("PS1"=>"test1", "PS2"=>13.1415, "PS3"=>"test2");

$key = "abcd";

$ret = i5_dtaq_send($dtaqHdl_KEY, $key, $parameter);

var_dump($ret);

$ret = i5_dtaq_receive($dtaqHdl_KEY, "EQ", $key);

var_dump($ret);

?>

  Back to Top

System Values

i5_get_system_value

Implemented in Compatibility Wrapper.

string i5_get_system_value(string name[, resource connection]).

Example:

 print "Date is: ".i5_get_system_value("QDATE");.

  Back to Top

User Spaces

i5_userspace_create

Implemented in Compatibility Wrapper.

bool i5_userspace_create(properties[, resource connection]).

i5_userspace_prepare

Implemented in Compatibility Wrapper.

resource i5_userspace_prepare(string name, array description [, resource connection]).

i5_userspace_get

Implemented in Compatibility Wrapper.

resource i5_userspace_get(resource user space, array params)

Note:

If i5_userspace_get() is used in a function, remember Compatibility Wrapper requires the use of i5_output() to extract the output.

i5_userspace_put

Implemented in Compatibility Wrapper.

bool i5_userspace_put(resource user space, params)

  Back to Top

Job Log List

i5_jobLog_list

Implemented in Compatibility Wrapper.

resource i5_jobLog_list( [array elements, resource connection] )

Use i5_jobLog_list_read function to retrieve the job entries from this handle.

i5_jobLog_list_read

Implemented in Compatibility Wrapper.

array i5_jobLog_list_read(resource list)

i5_jobLog_list_close

Implemented in Compatibility Wrapper.

bool i5_jobLog_list_close (resource handle)

  Back to Top

Active Job List

i5_job_list

Implemented in Compatibility Wrapper.

resource i5_job_list( [array elements, resource connection] )

Use i5_job_list_read function to retrieve the job entries from this handle.

i5_job_list_read

Implemented in Compatibility Wrapper.

array i5_job_list_read(resource list)

i5_job_list_close

Implemented in Compatibility Wrapper.

bool i5_job_list_close (resource handle)

  Back to Top

Data Areas

i5_data_area_create

Implemented in Compatibility Wrapper.

bool i5_data_area_create(string name, int size[, resource connection]).

i5_data_area_read

Implemented in Compatibility Wrapper.

string data_area_read(string name[, int offset, int length][, resource connection]).

If no offset is specified, all the area is read.

i5_data_area_write

Implemented in Compatibility Wrapper.

bool data_area_write(string name, string value[, int offset, int length][, resource connection]).

If no offset is specified, all the area is written. If value is shorter than length it is padded to the length. If it's longer it is truncated.

i5_data_area_delete

Implemented in Compatibility Wrapper.

bool data_area_delete(string name[, resource connection]).

  Back to Top

Spooled File

i5_spool_list

Implemented in Compatibility Wrapper.

resource i5_spool_list([array description][, resource connection])

i5_spool_list_read

Implemented in Compatibility Wrapper.

array i5_spool_list_read(resource spool_list)

i5_spool_list_close

Implemented in Compatibility Wrapper.

void i5_spool_list_close(resource spool_list)

i5_spool_get_data

Implemented in Compatibility Wrapper.

string i5_spool_get_data(string spool_name, string jobname, string username, integer job_number, integer spool_id [,string filename])

  Back to Top

Object Listing

i5_objects_list

Implemented in Compatibility Wrapper.

resource i5_objects_list(string library, [string name, string type, resource connection])

i5_objects_list_read

Implemented in Compatibility Wrapper.

array i5_objects_list_read (resource list)

i5_ objects_list _close

Implemented in Compatibility Wrapper.

bool i5_ objects_list_close (resource handle)

 

Read Also

  PHP XMLSERVICE Toolkit    
  iToolkit Service Class