PreviousNext
Help > API Functions > Commands & System values > i5_command
i5_command

 

Calls CL command. Output parameters can be returned.

 

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

 

 

Parameters

 

command

String: command name.

inputs

Array of “name => value” parts, name describing the call input parameters.

Names should match IBM i CL command parameter names.

If the array is empty or not provided, no input parameters are given.

If the value is integer, integer is passed.
If the value is string, quoted string is passed.
If the value is an array, the list of contained values is passed.

 

 

outputs

Array of “key => value” parts, which describes output parameters of the command. If not provided, no output parameters are defined.

Key of the array defines output parameter name of the IBM i command.

"rc" is a predefined name containing the result of the command.

Value can be string. If so - it defines a php variable name to accept the output parameter.

 

 

connection

Connection - result of i5_connect.

 

 

 

Return

True if OK, false if failed.

 

I5_ERR_PHP_HDLDFT

256

No default connection found.

I5_ERR_PHP_HDLCONN

257

This resource has no connection active.

I5_ERR_PHP_RESOURCE_BAD

261

No resource found.

I5_ERR_PHP_TYPEPARAM

262

Type of element x in parameter -1 must be y.

Type z was provided.

I5_ERR_PHP_INTERNAL

288

Internal error; please contact Aura Equipements.

error number 288

I5_ERR_PHP_NO_PARMNAME

293

Internal error; please contact Aura Equipements.

error number 293

I5_ERR_PHP_NO_ZVALUE

294

Internal error; please contact Aura Equipements.

error number 294

 

Examples

Example 1 : This is a direct, simple, command, with no output values.

 

 

/*This is a direct, simple, command, with no output values*/

$ret = i5_command("CLRSAVF FILE(EASYCOM/SAVOBJ)");

if (!$ret)

{

                   print_r("i5_command error : ".i5_errormsg().'<br/>');

}

 

Example 2 : This is also a direct command, but with separate values.

 

/* This is also a direct command, but with separate values*/

/* This is equivalent to SAVOBJ OBJ('PGM1 PGM2 PGM3')*/ /*LIB(MY_LIB) DEV(*SAVF) OBJTYPE(*PGM) SAVF(EASYCOM/SAVOBJ)*/

$Input = array(

 "OBJ" => array("PGM1","PGM2","PGM3"),

 "LIB" => "MY_LIB",

 "DEV" => "*SAVF",

 "OBJTYPE" => "*PGM",

 "SAVF" => "EASYCOM/SAVOBJ"

);

$Output = array();

$ret = i5_command("SAVOBJ", $Input, $Output);

 

Example 3 : Now, a command with return value.

 

/* Now, a command with return value */

/*This is like in CL: RTVJOBA USER(&USER) SYSLIBL(&SYSLIB)*/

                    $maVararray(

                    "user" => "user",

                    "usrlibl" => "usrlib",

                    "syslibl" => "syslib") ; 

 

                    $ret = i5_command ("RTVJOBA", array(), $maVar);

 

                    if (!$ret)

                    {

                                         print_r("i5_command error : ".i5_errormsg().'<br/>');

                    }

                    else

                    {

                                         print "User : $user<br>";

                                         print "User library: $usrlib<br>";

                                         print "system libs list : $syslib<br>";

        }