Reference Manual - Zend Technologies
-
Rating
-
Date
November 2018 -
Size
2.4MB -
Views
977 -
Categories
Transcript
Zend Server 5 for IBM i Reference Manual By Zend Technologies www.zend.com Abstract This is the Reference Manual for Zend Server for IBM i Version 5.0 Beta. The information in this document is subject to change without notice and does not represent a commitment on the part of Zend Technologies Ltd. No part of this manual may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or information storage and retrieval systems, for any purpose other than the purchaser’s personal use, without the written permission of Zend Technologies Ltd. All trademarks mentioned in this document, belong to their respective owners. © 1999-2009 Zend Technologies Ltd. All rights reserved. Zend Server for IBM i Reference Manual, issued October 2009. DN: ZIBMi-RM-211009-5.0-001 Table of Contents Zend Server for IBM i ...................................................................................................................... 1 Overview ...................................................................................................................................... 1 About ............................................................................................................................................ 2 Installation Directories .................................................................................................................. 2 Password Management ............................................................................................................... 3 Support......................................................................................................................................... 4 Zend Support Center ................................................................................................................ 4 Zend Forums ............................................................................................................................ 4 Online Documentation .............................................................................................................. 4 Open a Support Ticket (Only Available in Zend Server) .......................................................... 4 Zend PHP Email Updates ........................................................................................................ 4 Zend Developer Zone Resource Center .................................................................................. 5 Feedback .................................................................................................................................. 5 Administration Interface ............................................................................................................... 6 General Layout ......................................................................................................................... 6 Monitor Tab .................................................................................................................................. 7 Dashboard ................................................................................................................................ 7 Events....................................................................................................................................... 8 Event Details ............................................................................................................................ 9 Jobs ........................................................................................................................................ 12 Queue Statistics ..................................................................................................................... 14 Code Tracing .......................................................................................................................... 15 Server Info .............................................................................................................................. 21 PHP Info ................................................................................................................................. 22 Logs ........................................................................................................................................ 23 Applications ............................................................................................................................ 24 Applications window ............................................................................................................... 25 Demo Applications window .................................................................................................... 25 Rule Management Tab .............................................................................................................. 27 Monitoring ............................................................................................................................... 27 Edit Rule (Monitoring)............................................................................................................. 28 Caching .................................................................................................................................. 30 Edit Rule (Caching) ................................................................................................................ 31 Recurring Jobs ....................................................................................................................... 33 Rule Information ......................................................................................................................... 34 Server Setup Tab ....................................................................................................................... 35 Components ........................................................................................................................... 35 Extensions .............................................................................................................................. 37 Directives ................................................................................................................................ 38 Debugger ................................................................................................................................ 39 Monitor Configuration ............................................................................................................. 40 Job Queue .............................................................................................................................. 42 Zend Server for IBM i 5250 Bridge Settings........................................................................... 43 Administration Tab ..................................................................................................................... 44 Password and License ........................................................................................................... 44 Updates .................................................................................................................................. 45 Tasks.......................................................................................................................................... 47 Working with Zend Server for IBM i ....................................................................................... 47 Getting Started with Zend Server for IBM i ............................................................................ 50 Configuring Zend Server for IBM i .......................................................................................... 53 Working with Extensions ........................................................................................................ 54 Working with Logs .................................................................................................................. 56 iii Zend Server 5 for IBM i Reference Manual Working with Events ............................................................................................................... 60 Creating a Job ........................................................................................................................ 69 Working with Code Tracing .................................................................................................... 73 Working with the Debugger .................................................................................................... 76 Working with the Zend 5250 Bridge ....................................................................................... 78 Working with Components ..................................................................................................... 80 Working with Directives .......................................................................................................... 82 Working with Optimizer+ ........................................................................................................ 83 When Not to use Optimizer+ (Blacklist)? ............................................................................... 83 Working with Zend Guard Loader .......................................................................................... 86 Working with Data Cache ....................................................................................................... 87 Working with Java Bridge ....................................................................................................... 90 Working with Local Debugging ............................................................................................... 93 Working with Monitoring ......................................................................................................... 94 Disabling Event Rules ............................................................................................................ 95 Working with Caching ............................................................................................................. 96 Components ............................................................................................................................. 101 Debugger .............................................................................................................................. 102 Optimizer+ ............................................................................................................................ 103 Guard Loader ....................................................................................................................... 104 Data Cache........................................................................................................................... 105 Java Bridge........................................................................................................................... 106 Zend 5250 Bridge ................................................................................................................. 108 Zend Framework .................................................................................................................. 112 Monitor.................................................................................................................................. 114 Page Cache .......................................................................................................................... 116 Job Queue Component ........................................................................................................ 117 Zend Code Tracing ............................................................................................................... 119 Zend 5250 Bridge ................................................................................................................. 120 Applications .......................................................................................................................... 124 Working with the Demo Applications .................................................................................... 125 Working with the Zend 5250 Bridge ..................................................................................... 127 Zend Server for IBM i 5250 Bridge Settings......................................................................... 129 Working with the Zend Server 5250 Emulator ..................................................................... 130 CSS Editing .......................................................................................................................... 136 Opening Files in Zend Studio ............................................................................................... 139 5250 Bridge API ................................................................................................................... 141 Working with the 5250 Bridge API........................................................................................ 143 Using the 5250 Bridge API ................................................................................................... 144 Troubleshooting the Zend 5250 Bridge ................................................................................ 150 FAQ ...................................................................................................................................... 151 Reference Information ............................................................................................................. 154 Java Bridge Use Cases ........................................................................................................ 155 PHP Extension List............................................................................................................... 159 Zend Server Extension List - PHP 5.2 ................................................................................. 160 Zend Server Extension List - PHP 5.3 ................................................................................. 165 Adding Extensions ................................................................................................................ 170 UNIX: Compiling PHP Extensions forZend Server for IBM i ................................................ 172 Info Messages ...................................................................................................................... 178 API Reference ............................................................................................................................. 180 Introduction .............................................................................................................................. 180 Zend Debugger ........................................................................................................................ 181 PHP API ............................................................................................................................... 181 INI Directives: ....................................................................................................................... 181 Zend Optimizer+ ...................................................................................................................... 185 PHP API ............................................................................................................................... 185 iv Table of Contents External Configuration File: Optimizer+ blacklist file ............................................................ 185 INI Directives: ....................................................................................................................... 185 Zend Guard Loader .................................................................................................................. 192 PHP API ............................................................................................................................... 192 INI Directives: ....................................................................................................................... 195 Zend Data Cache ..................................................................................................................... 197 PHP API ............................................................................................................................... 197 INI Directives: ....................................................................................................................... 200 Zend Java Bridge ..................................................................................................................... 203 PHP API ............................................................................................................................... 203 INI Directives: ....................................................................................................................... 207 Zend Extension Manager ......................................................................................................... 209 Zend Utils ................................................................................................................................. 211 INI Directives: ....................................................................................................................... 211 Zend Page Cache .................................................................................................................... 212 PHP API ............................................................................................................................... 212 INI Directives: ....................................................................................................................... 213 Zend Monitor ............................................................................................................................ 216 PHP API ............................................................................................................................... 216 INI Directives: ....................................................................................................................... 219 Zend 5250 Bridge API.............................................................................................................. 227 Zend 5250 Bridge Object Oriented API................................................................................ 227 Zend 5250 Bridge Procedural API Functions ....................................................................... 233 Zend 5250 Bridge Use Case Examples ............................................................................... 237 Zend Monitor Node Daemon ................................................................................................ 240 Zend Job Queue ...................................................................................................................... 243 PHP API ............................................................................................................................... 243 INI Directives: ....................................................................................................................... 255 Zend Job Queue Daemon........................................................................................................ 258 INI Directives: ....................................................................................................................... 258 Zend Tracer.............................................................................................................................. 265 PHP API ............................................................................................................................... 265 PHP Toolkit for IBM i ................................................................................................................... 272 Introduction to the PHP Toolkit for IBM i .................................................................................. 272 PHP Toolkit for IBM i ................................................................................................................ 273 PHP Toolkit Classes (sample) ................................................................................................. 273 INSTALLATION........................................................................................................................ 274 Zend Studio IDE templates ...................................................................................................... 274 PHP Toolkit Functions .......................................................................................................... 275 PHP Toolkit Data Description ............................................................................................... 318 Program Samples ................................................................................................................. 327 Data Queues ........................................................................................................................ 330 PCML Program Call - PCML Description Used in the PHP Program .................................. 335 PCML Program Call 2 - PCML File External to PHP Program ............................................. 337 List of an RPG Program, "TESTSTRUC", Called by the PCML Sample Programs ............. 338 Web Services ....................................................................................................................... 339 Web Services - Client Side................................................................................................... 340 IBM i Toolkit Templates ........................................................................................................... 341 Zend Server for IBM i Installation Guide ..................................................................................... 344 Installing Zend Server for IBM i................................................................................................ 345 Installation Directories .............................................................................................................. 345 Choosing Which Distribution to Install for IBM i ....................................................................... 346 Silent Installation ...................................................................................................................... 347 Interactive Installation .............................................................................................................. 348 To run an interactive installation: ......................................................................................... 348 Windows-Based Installation ..................................................................................................... 353 v Zend Server 5 for IBM i Reference Manual To install Zend Server for IBM i through Windows: ............................................................. 353 MySQL Installation ................................................................................................................... 355 Uninstalling Zend Server for IBM i ........................................................................................... 359 Post Installation ........................................................................................................................ 360 Package Setup and Control Scripts IBM i ............................................................................ 361 Starting Zend Components on IBM i .................................................................................... 361 Ports and Services for IBM i ................................................................................................. 362 Changing the Apache Port ................................................................................................... 362 Installed Components for IBM i ................................................................................................ 363 Installation Directories .......................................................................................................... 363 Upgrading Zend Server for IBM i ............................................................................................. 367 Upgrading to a Newer Version of Zend Server for IBM i ...................................................... 367 Zend Server for IBM i ........................................................................................................... 367 Upgrading Zend Server for IBM i ......................................................................................... 367 Updating Zend Server for IBM i ............................................................................................... 369 Manual Rollback ................................................................................................................... 369 Welcome to Zend Server for IBM i ....................................................................................... 370 7 Ways to Get Started with PHP on IBM i ............................................................................ 370 Accessing PHP Open Source Applications .......................................................................... 371 Registration .............................................................................................................................. 372 Setting a Password .................................................................................................................. 372 Licenses ................................................................................................................................... 373 How do I just take a look at the product? ............................................................................. 373 How do I get a License? ....................................................................................................... 373 I already have a License - what do I do? ............................................................................. 373 License Expiration ................................................................................................................ 374 Zend Server for IBM i Setup Menu .......................................................................................... 375 Sign-On ................................................................................................................................ 376 Main Menu ............................................................................................................................ 377 Changing the Administration Console Password ................................................................. 379 Update using PTFs menu..................................................................................................... 380 Runing the Support Tool ...................................................................................................... 381 Zend Server for IBM i Service Management ........................................................................ 382 Start Zend Server Subsystem .............................................................................................. 382 Stop Zend Server Subsystem .............................................................................................. 383 Start Apache server instances ............................................................................................. 383 Stop Apache server instances.............................................................................................. 383 ReStart Apache server instances ......................................................................................... 383 Start PHP Toolkit service (i5_COMD) .................................................................................. 383 Stop PHP Toolkit service (i5_COMD) .................................................................................. 384 Monitor Management Menu ................................................................................................. 384 Java Bridge Management Menu .......................................................................................... 385 PRNGD (ZC_STR_PRN) job Management Menu ............................................................... 386 Start PRNGD (ZS_STR_PRN) job ....................................................................................... 386 Stop PRNGD (ZS_STR_PRN) job ...................................................................................... 386 Add restart PRNGD (ZS_STR_PRN) job to scheduler ....................................................... 387 Work with PRNGD (ZS_STR_PRN) scheduled jobs............................................................ 387 Java Bridge Management Menu .......................................................................................... 388 MySQL Management menu ..................................................................................................... 389 Start MySQL subsystem....................................................................................................... 389 Stop MySQL subsystem ....................................................................................................... 389 Start MySQL daemon ........................................................................................................... 389 Stop MySQL daemon ........................................................................................................... 390 5250 Bridge Management Menu.............................................................................................. 391 Restart 5250 Bridge Server ..................................................................................................... 391 Reset 5250 Bridge Environment .............................................................................................. 391 vi Table of Contents Zend Server Best Practices ......................................................................................................... 392 Introduction .............................................................................................................................. 392 Performance............................................................................................................................. 393 What's in the Performance Section ...................................................................................... 393 Optimizing Zend Server Performance .................................................................................. 394 Fine Tuning Optimizer+ ........................................................................................................ 396 Disabling Code Change Auto-Detection .............................................................................. 396 Decreasing Code Validation Frequency............................................................................... 396 Configuring PHP for Performance ........................................................................................ 397 IIS Configuration Optimization ................................................................................................. 401 Tuning FastCGI Configuration for IIS6 ................................................................................. 401 Tuning FastCGI Configuration for IIS7 ................................................................................. 402 Security .................................................................................................................................... 403 What's in the Security Section .............................................................................................. 403 Configuring Debugger Access Control ................................................................................. 404 Securing the Administration Interface .................................................................................. 405 Configuring PHP for Security ............................................................................................... 406 Development ............................................................................................................................ 408 What's in Development......................................................................................................... 408 Working with Zend Framework............................................................................................. 409 Loading Zend Framework Classes ...................................................................................... 409 Configuring Zend Framework .................................................................................................. 411 Configuring Zend Server for IBM i to Run a Zend Framework Application .......................... 411 Where is My Apache Configuration File? ............................................................................. 412 Advanced Diagnostics with Zend Server ................................................................................. 413 Advanced Diagnostics with Zend Server ............................................................................. 413 Custom Event ....................................................................................................................... 414 Slow Function Execution ...................................................................................................... 416 Function Error ....................................................................................................................... 418 Slow Request Execution ...................................................................................................... 420 High Memory Usage ............................................................................................................. 422 Inconsistent Output Size ...................................................................................................... 423 PHP Error ............................................................................................................................. 424 Java Exception ..................................................................................................................... 426 Database Error ..................................................................................................................... 427 vii Zend Server for IBM i Overview Zend Server for IBM i is a Web application server geared towards various usage models and environments. This product is intended for architects, IT managers and system administrators who want to maintain high quality of service on their Websites by: Boosting application performance and throughput Maintaining application reliability and security Improving application management 1 Zend Server 5 for IBM i Reference Manual About Zend Server for IBM i provides optimized PHP distribution for developers. Zend Server for IBM i includes a tested and certified version of PHP and a set of tools to set up and optimize your environment. These tools are presented in an improved Administration Interface designed to provide all the tools and technology necessary to support PHP developers. Special attention has been given to creating consistency across operating systems to ensure interoperability and facilitate the needs of diverse environments that use Linux, and Windows . The PHP version is PHP 5.2 which has been tested and optimized for development use. Commonly used extensions and Zend Framework are included with the PHP to provide a onestop shop for all the resources that developers need to create PHP Web applications. A complementary set of tools is provided with Zend Server for IBM i to optimize and extend your PHP capabilities. The tools included in Zend Server for IBM i are described in detail in the Components Section. Instructions on how to work with each component are provided in the Tasks section, where each possible task is described in detail from start to end. To get started with Zend Server for IBM i , click here. Installation Directories Not all users decide to install their software in the same location. To reflect this requirement, all paths in this document have been replaced with the following prefix:\n"; print "Java vendor=".$system->getProperty("java.vendor")."
\n\n"; print "OS=".$system->getProperty("os.name")." ". $system->getProperty("os.version")." on ". $system->getProperty("os.arch")." Message $a "; echo "Job queue Name : " . $ret[I5_JOB_QUEUE_NAME] . ", Response Id : " . $ret[I5_JOB_PROCESS_ID] . " "; echo "Message : " . $ret[I5_LOBJ_MSG]. ", "; echo "Message : " . $ret[I5_LOBJ_MSG]. ",
\n"; ?>
If the Java Bridge is correctly installed and running, you should receive the following response: Friday, June 13, 2008 at 8:45:57 PM U.S Daylight Time class java.lang.System Java version=1.6.0_06 Java vendor=Sun Microsystems Inc. OS=Linux 2.6.25.3-18.fc9.i686 on i386
This output shows the date, Java version, vendor and operating system and indicates that the connection is complete. If you receive an error message instead of the expected output information, one of the following problems may have occurred: 1. The Java Bridge is not installed 2. The Java Bridge extension is not running (Server Setup | Components) 3. The Java Bridge Server needs to be restarted (Server Setup | Components) 4. The requested .jar file does not appear in the environment's classpath. Once the connection is established, you can start using the API to call Java objects from your PHP.
91
Zend Server 5 for IBM i Reference Manual
Before using the Java Bridge API Before you start incorporating the Java Bridge API in your code, you must be aware that when you call Java from PHP, you must use Java coding standards to call the correct objects, because the Java Bridge does not perform dynamic data conversion. You must perform the type conversion in your PHP code. For example, Example: If you call a Java method that looks like this: public void doSomething(int i);
Using what you would expect to work in PHP: $var = "1" $javaObject->doSomething($var);
The Java Bridge throws an exception. To avoid this, use the following line of code to convert the parameter from a string to a numeric value before the Java Bridge passes it: $javaObject->doSomething($var + 0);
For more information, see the API, or Java Bridge Use Cases.
92
Zend Server for IBM i
Working with Local Debugging Local debugging occurs when your entire environment (Zend Studio for Eclipse, Debugger and Zend Server for IBM i ) is located on a single machine.
When working with an IDE such as Zend Studio for Eclipse, your project files are, in most cases, placed in a location that you have defined. To run the files on the Web Server, you must first move the files to the Web Server's document management directory called "htdocs".
93
Zend Server 5 for IBM i Reference Manual
Working with Monitoring To access the Monitoring page, go to Rule Management | Monitoring.
This page is the central management area for defining the conditions by which events are generated (as displayed in Monitor | Events).
Creating Events Event generation is an out-of-the-box feature. On installation, the Monitor component begins to collect and report information about events, according to the Monitor's default settings. The resulting events are displayed in Monitor | Events. To further enhance monitoring effectiveness, event thresholds can be customized. In a similar manner, thresholds can be gradually modified to not only reflect improvements in performance, but also to verify that problematic issues have been resolved.
Configuring Events Events can be configured according to each environment’s specific requirements. The main configuration changes that should be performed relate to tuning rule values and defining a list of functions and PHP errors to monitor. The following procedure describes how to configure event rules
To configure event rules: 1. Go to Rule Management | Monitoring. 2. Select a rule from the list. Hovering over the information icon
displays a
description of the selected event and the event’s parameters. 3. Click Edit to change the default settings according to your requirements. Each event type has different configuration options suited to the nature of the event. 4. Scroll to the bottom of the page and click Save to save changes. The new settings are applied after you click Restart PHP. To return to the main Monitoring page, click Cancel, Save or use your browser's Back button. See Edit Rule (Monitoring) for more information about rule settings.
94
Zend Server for IBM i
Disabling Event Rules In some cases, there may be events that are either not applicable to your system or unnecessary. Events are disabled from the Monitor page. When an event is disabled, the event is not monitored and information is not stored for the event.
To disable event rules: 1. Go to Rule Management | Monitoring. 2. Select a rule from the list. Hovering over the information icon
displays a
description of the selected event and the event’s parameters. 3. Click Disable to stop the Monitor from collecting and reporting information relevant to this event type. This event type is no longer monitored.
95
Zend Server 5 for IBM i Reference Manual
Working with Caching To access the Caching page, go to Rule Management | Caching.
The Page Cache is used to speed-up recurring executions of PHP scripts in your application. This is achieved by caching the PHP output (HTML) for specific URLs on first execution, to reuse the cached data for subsequent calls. Cache behavior is defined using a flexible rule system that allows you to maintain the dynamic capabilities of your applications.
As opposed to other caching alternatives (Zend Server for IBM i Data Cache and Zend Framework Zend Cache), the Zend Server for IBM i Cache does not require any code changes and can be easily applied to existing applications. Moreover, while other caching solutions still run some code on recurring executions, the cache does not run any code to display the cached content, which results in improved performance.
Creating URL cache rules with Zend Server for IBM i is a two-step process. In step one, you define the basic URL and conditions to apply. In step two, you define the cache duration and output options.
The following procedure describes how to create a cache rule.
To create a Cache rule: 1. Go to Rule Management | Caching 2. Click
to open the New Rule page.
3. Name the rule. Make sure the name is descriptive and easy to remember: This name is what will appear in the main Caching page. 4. Enter the information according to the following steps and click Save to apply the changes:
96
Zend Server for IBM i
Step 1: Caching Conditions 1. Use the fields to define the URL that you want to cache. A URL can be an exact URL or a representation of a pattern of URLs using Regular Expressions, which can be either case sensitive or case insensitive. Example: Exact URL
This representation sets the Page Cache to cache the URL http://www.zend.com/index only.
URL pattern using Regular Expressions
Note: Using regular expressions consumes more time and CPU than using exact URLs. This example sets the Page Cache to cache the following:
Matches regex - Any URL that matches this pattern is cached.
Scheme - Only URLs that begin with 'http' are cached (the alternatives are 'https or 'either').
Host - The host name and port part (optional) of the URL. By using a regular expression, you can specify whether to cache URLs that begin (or do not begin) with "www". For example: (www\.)? - Indicates that the URL may or may not begin with 'www.\'.
Path - the path and query part of the URL. For example: /.* - Indicates that any string after the host name 'zend.com/articles/' is acceptable. To be precise, it represents 0 or more of any character.
2. Click
to create additional caching rules based on
HTTP requests and session parameters. There is no limit to the amount of conditions that can be added.
97
Zend Server 5 for IBM i Reference Manual
Example: How can we configure the system to use only cached content when a user is not logged in? Usage Scenario: Websites (portals, news sites, forums...) that provide different content to premium users and non-registered users.
Assuming that the _SESSION 'username' parameter is used to store the name of a currently logged in user, create a rule based on this parameter, as follows:
This sets the Page Cache to cache content only when the _SESSION parameter 'username' is not set. Subsequently, users that do have the _SESSION 'username' set are presented with a live version of the page.
If necessary, we can extend this limit to include all users whose 'username' _SESSION parameter equals 'guest' as follows:
Note: Square brackets are not required for non-nested variables when referring to superglobal variables in caching conditions . If you do not use square brackets, the system adds them automatically after you click "Save". 3. Use the match options to define if you want to cache only if all of the conditions are met ("Match all of the above") or if any one of the conditions is met ("Match any of the above"). If you use the option "Match any of the above", the pages are cached both when the parameter 'username' does not exist or if it equals 'guest'. If you use the option "Match all of the above", the pages are cached either when the parameter 'username' does not exist or when it equals 'guest'. This completes Step 1 of creating a Page Cache Rule.
98
Zend Server for IBM i
Step 2: Cache Output 1. Set the cache duration in seconds. After that time, the cache is refreshed and a newer version is created. For example, 600 seconds is ten minutes. 2. Choose to create compressed cache copies. This option allows you to disable the creation of a gzip-compressed version of each cached page, as long as it is larger than 1KB. You should normally leave this option checked. By default, Zend Server for IBM i creates a compressed version of each cached page and stores it alongside the original version. This compressed version is sent to browsers that support gzip compression (all modern browsers support this) instead of the uncompressed version. For typical HTML, XML or other text-based outputs, using the compressed version can save about 90% of the bandwidth and improve page load times. In addition, the compressed copy is saved in your cache so the CPU-intensive process of real-time compression is not required. However, if you are caching a PHP script that outputs binary data (for example JPEG or PNG images, ZIP or EXE files, PDFs, etc.) which cannot be further compressed, you should un-check this option to avoid redundant processing. For more information, see: Page Cache. 3. Click
to create different cached copies according to specific values.
This creates more than one version of the page in the cache, based on specific conditions. Example: The following example demonstrates how to create different copies of cached information, based on the _GET parameter 'language'.
This sets Caching to create a different copy for each different value of _GET 'language' (for the content that was cached based on the rules defined in steps 1 and 2). This example demonstrates how to use Caching for multilingual pages that handle the same content in different languages. This completes the last step of creating a Cache Rule. Scroll to the bottom of the page (Rule Management | Caching) and click "Save" to save the rule information and "Restart PHP" to activate the rule. To edit a rule, go to Rule Management | Caching and click Edit next to the rule you want to edit.
99
Zend Server 5 for IBM i Reference Manual
To clear the information in the cache for a specific rule, go to Rule Management | Caching and click Clear next to the rule you want to edit.
100
Zend Server for IBM i
Components Zend Server for IBM i is comprised of several components that each contribute important functionality to facilitate the development process. The components are:
Debugger - The Zend Debugger communicates with the Zend (PHP) Engine to retrieve runtime information and present it in Zend Studio for root cause analysis.
Optimizer+ - The Zend Optimizer+ component speeds up PHP execution via opcode caching and optimization.
Guard Loader - The Zend Guard Loader is used in order to run PHP scripts that are encoded with Zend Guard.
Data Cache - The Zend Data Cache component provides a set of PHP functions to improve performance, by storing data in the cache.
Java Bridge - The Zend Java Bridge component makes it possible to use Java classes and code from within PHP.
Zend 5250 Bridge - The Zend 5250 Bridge component makes it possible to use the 5250 Bridge on Zend Server for IBM i.
Zend Framework - An open source framework for developing Web applications and Web services with PHP.
Monitor - The Zend Monitor component is integrated into the runtime environment and serves as an alerting and collection mechanism for early detection of PHP script problems.
Page Cache - The Zend Page Cache component is used to cache the entire output of PHP scripts, without changing the PHP code.
Job Queue Component - The Jobs Component is used to streamline offline processing of PHP scripts.
Zend Code Tracing - Code Tracing enables real-time execution flow recording in Production Environments.
Click on a link to view a full description of the components architecture. To see how to work with a component, select a topic that begins with "Working with..." from the Tasks section. For a short description of each component and where it is installed, see the Installed Components section in the Installation Guide.
101
Zend Server 5 for IBM i Reference Manual
Debugger The Zend Debugger component enables remote debugging of PHP scripts with Zend Studio. The Zend Debugger communicates with the Zend (PHP) Engine to retrieve runtime information and present it in Zend Studio for root cause analysis purposes. Note: If your machine has multiple IP addresses, make sure you define all the IPs as allowed hosts in Zend Server for IBM i. The Zend Debugger API communicates with the Zend (PHP) engine to reveal PHP runtime information such as variables, call stack and environment information. This information is then displayed and set up in Zend Studio to enable server side debugging, profiling and code coverage.
102
Zend Server for IBM i
Optimizer+ The Zend Optimizer+ component speeds up PHP execution through opcode caching and optimization.
The Zend Optimizer+ improves PHP performance by storing precompiled script bytecode in the shared memory. This eliminates the stages of reading code from the disk and compiling it on future access. For further performance improvement, the stored bytecode is optimized for faster execution. This component works out-of-the-box and therefore does not require any configuration or changes to your code.
The Zend Optimizer+ speeds up PHP execution and increases server performance, resulting in better Web application performance.
This component is intended for PHP developers who run complex PHP applications and can benefit from bytecode caching (which is especially helpful for working with Zend Framework). Note: The Optimizer+ works exclusively with Apache or FastCGI environments (no CLI or CGI support).
103
Zend Server 5 for IBM i Reference Manual
Guard Loader The Zend Guard Loader runs PHP scripts that are encoded with Zend Guard.
The Zend Guard Loader runs outputs created by a separate product available from Zend, which provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line.
The Guard Loader must be installed on each Web server that runs files that were encoded with, or use, Zend Guard licenses. The Zend Guard Loader translates encoded files to a format that can be parsed by the Zend Engine. This runtime process uses the Zend engine as a trigger to start the Zend Guard Loader component.
Zend Guard Zend Guard is a separate product available from Zend that provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line. To view the API, click Zend Guard Loader. For additional information on using Zend Guard, see the Zend Guard User Guide, available online from http://files.zend.com/help/Zend-Guard/zend-guard.htm
104
Zend Server for IBM i
Data Cache The Zend Data Cache component provides a set of PHP functions to improve performance by storing data in the cache. The Zend Data Cache is used to cache different types of data (e.g., strings, arrays and objects), as well as script output or script output elements for various durations. Items can be stored in shared memory (SHM) or to disk. Namespaces are supported, to group cached objects for easy management.
Data Caching is primarily used when it is impractical or impossible to cache the entire page output, such as when sections of the script are fully dynamic, or when the conditions for caching the script are too numerous. An example of this kind of usage is when some of the output is a form: The data may include credit card numbers, addresses and other kinds of information that should not be cached, for security reasons. For more information, see Working with the Data Cache. The Data Cache API includes the following functionality :
Storing variables to the cache
Fetching variables to the cache
Deleting variables from the cache
Clearing the cache
Disk/memory (SHM) storage
Caching using namespaces
Cache folder depth configuration
105
Zend Server 5 for IBM i Reference Manual
Java Bridge The Zend Java Bridge provides PHP developers with a way to use existing Java code and build PHP applications that use Java code. The Java Bridge integrates Java code in PHP by connecting the PHP object system with the Java Bridge object system. Note: The Java Bridge requires that you have SUN Microsystems JRE 1.4 (or later) or IBM's Java 1.4.2 (or later) installed on your computer. During (or after ) installing, (depending on the installation type, you are prompted to direct the installer to the JRE location. You should, therefore, already have JRE installed. 64-bit JRE is not supported. More information about JRE and the latest updates can be obtained from SUN Microsystems’s website. The Java Bridge PHP extension adds functions that allow you to instantiate new Java classes from inside your PHP script. Once a Java class is instantiated, the Java Bridge gets a message from the Zend Engine to execute the Java code. The Java Bridge executes the script and returns the results to the Zend Engine.
Zend Server for IBM i includes the Java Bridge PHP Extension and the ability to restart the Java Bridge and configure the Java Bridge settings (from Server Setup | Components). The Java Bridge is an optional component that is installed differently, depending on the operating system (WIN, UNIX) and the installation method format (EXE, DEB, RPM). Once the extension is installed and its status is On, PHP code can use the Java Bridge API to call Java objects.
The process of calling Java objects in PHP is described in the following diagram:
106
Zend Server for IBM i
Advantages The Zend Java Bridge provides the following advantages:
J2EE application servers can be extended to include the advantages that PHP offers (relative to other Web-enablement languages), such as reduced development time, reduced time-to-market, lower TCO (Total Cost of Ownership), etc.
PHP-centric companies can take advantage of J2EE services that are not present in scripting languages.
The PHP/Java Bridge provides the ability to interact with plain Java objects.
The Java Bridge operates without the overhead of a JVM for each Apache process.
The Java Bridge consumes a set amount of memory that is disproportionately small relative to the amount of activity that it handles.
107
Zend Server 5 for IBM i Reference Manual
Zend 5250 Bridge The 5250 Bridge is a PHP based solution for running interactive applications in the i/OS environment. This provides an answer to the challenges faced with directly accessing the 5250 data stream. The 5250 Bridge provides a method for running interactive i/OS based applications through a browser. There are several distinct usages for this solution: 1. Providing a web-based interface to replace the traditional green-screen display – allowing for a wider range of functionality and display options. 2. Creating a web-based version of legacy applications – opening up the functionality to users who are not familiar with the i/OS environment and extending the usage to a wider range of users. 3. Incorporating information from i/OS into integrated applications – providing System Integrators with tools to ensure true integration with data/applications located on i/OS servers.
5250 Predecessor
108
Zend Server for IBM i
How the Zend 5250 Bridge Works The diagram below shows how the 5250 Bridge can be used to access information from a 5250 program and leverage it to either be displayed in a browser-based environment or to populate screen values: 1. PHP sends a 'start session' request to the 5250 Program using the 5250 Bridge. 2. The 5250 Bridge returns a confirmation to PHP that the session has started. 3. The 5250 Bridge sends current screen information in XML format to PHP (e.g. format name, input and output fields and current cursor position). 4. The XML data can be automatically entered into the program or sent on in an html format for user input.
Flow depicting the interaction between the 5250 Bridge, the i/OS server, and PHP
109
Zend Server 5 for IBM i Reference Manual
Overview The Zend 5250 Bridge is a PHP API which offers several modernization options for running interactive (5250) applications in a Web environment. The 5250 Bridge assists developers who are interested in PHP as a strategic Web development platform for their organizations.
The 5250 Bridge is a set of functions that developers can use to import 5250 functionality into a Web-based environment. The 5250 Bridge offers 2 models of operation: 1. 5250 Emulator - Displays your IBM i application in a browser by emulating your application. 2. 5250 Bridge API - Web-enables your application and allows for complete customization options.
The Working with the 5250 Bridge section will help you to decide which mode of operation is suitable for you. Note: In all the cases, the business logic continues to run normally on the IBM i. The options given are for presentation level changes and further in-browser functionality and PHP development. Note: The 5250 Bridge uses the IBM WebFace server which allows the running of interactive (5250) programs in batch mode. IBM WebFace server APIs do not support Workstation IDs. The display device starting with QQF is created and used by the WebFace APIs.
Advantages The following list describes a few key advantages to implementing the 5250 Bridge:
Does not require WebSphere Application Server (WAS), resulting in lower CPW requirements providing the ability to run applications on less expensive machines.
No 5250 workload - use batch processes for green screen programs instead of interactive processes.
No display file source required - works on objects.
Allows access to a variety of IBM i resources that do not currently have an interactive option.
Transfer presentation data only - Only transfers the information displayed on screen, reducing traffic.
110
Zend Server for IBM i
Ability to encapsulate a 5250 program into Web Services - present the application as a Web service to grant access from any client without limitations.
Free single connection for evaluating the 5250 Bridge even after the trial license expires. This provides the ability to create a fully functioning Web based application in PHP based on content currently only accessible from the 5250 emulation.
Extendibility with features only applicable to Web based applications such as Rich-text, sound and images, AJAX, Mashups.
Note: The Zend Server for IBM ir trial license allows creating unlimited interactive (5250) sessions. Once the trial license expires the interactive (5250) sessions will be limited to one at a time. Fully licensed versions permit creating unlimited interactive (5250) sessions.
111
Zend Server 5 for IBM i Reference Manual
Zend Framework Zend Framework is a high quality, open source framework for developing Web applications and Web services with PHP. Built in the true PHP spirit, the Zend Framework delivers ease-of-use and powerful functionality. It provides solutions for building modern, robust and secure websites.
Zend Framework Resources All the developer resources can be found at: http://framework.zend.com/
Why Zend Framework (Taken from: http://framework.zend.com/whyzf/overview) Extending the art and spirit of PHP, Zend Framework is based on simplicity: Object-oriented best practices, corporate friendly licensing and a rigorously tested agile code base. Zend Framework is focused on building more secure, reliable and modern Web 2.0 applications and Web services, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo!, and Flickr, as well as API providers and cataloguers like StrikeIron and ProgrammableWeb.
Expanding on these core themes, we have implemented Zend Framework to embody extreme simplicity and productivity, the latest Web 2.0 features, simple corporate-friendly licensing and an agile, well-tested code base that your enterprise can depend upon.
Extreme Simplicity & Productivity We designed Zend Framework with simplicity in mind. To provide a lightweight, loosely-coupled component library simplified to provide 4/5s of the functionality everyone needs and that lets you customize the other 20% to meet your specific business needs. By focusing on the most commonly needed functionality, we retain the simplified spirit of PHP programming, while dramatically lowering the learning curve - and your training costs – so developers get up-to-speed quickly. We do this with:
Extensible and well-tested code base
112
Flexible architecture
No configuration files necessary to get going
Zend Server for IBM i
Frameworks and best practices mean reduced training costs and quicker time-to-market – important factors in adoption decisions. Built so you can pick and choose just the pieces you need to turbocharge your web applications – all your developers know where to find their PHP / Zend Framework code, which speeds new development and reduces maintenance costs.
Latest Web Development Features AJAX support through JSON – meet the ease-of-use requirements your users have come to expect Search – a native PHP edition of the industry-standard Lucene search engine Syndication – the data formats and easy access to them your Web 2.0 applications need Web Services – Zend Framework aims to be the premier place to consume and publish web services High-quality, object-oriented PHP 5 class library – attention to best practices like design patterns, unit testing and loose coupling
Friendly & Simple Licensing, Safe for the Enterprise Based on the simple and safe new BSD license, with Zend Framework's License, you can rest assured that your code is compliant, unimpeachable and protected as you see fit. We also require all contributors to the open source Zend Framework to complete and sign a Contributor License Agreement (CLA) — which is based on the standard open-source Apache license — to protect your intellectual property (that is, your added-value) built on Zend Framework.
Fully Tested – Extend Safely and Easily Tested. Thoroughly. Enterprise-ready and built with agile methods, Zend Framework has been unit-tested from the start, with stringent code coverage requirements to ensure that all code contributed has not only been thoroughly unit-tested, but also remains stable and easy for you to extend, re-test with your extensions and further maintain.
113
Zend Server 5 for IBM i Reference Manual
Monitor The Zend Monitor component is integrated into the runtime environment and serves as an alerting and collection mechanism for early detection of PHP script problems. The Zend Monitor is a Zend Server for IBM i component that integrates into the PHP runtime environment and watches for various events such as errors, failing functions, slow scripts, database errors, etc. When an event occurs, the Zend Monitor collects and reports all the relevant debugging information. This information can then be used to perform root cause analysis.
What is an Event? Events are governed by rules created in Rule Management | Monitor. Rules define the nature of an event and the parameters for capturing event related information in an application. Events are only created when the monitor component is running (Server Setup | Components).
By definition, an event is a collection of information that can be used to investigate what caused the rule to trigger an event. The information collected varies according to the rule type.
Aggregation If events are triggered by the same rule and have similar characteristics – i.e., filename, URL, line etc – they are aggregated into a single issue. If they do not have similar characteristics, a separate (new) issue is created. Inside a single issue, events are divided into groups according to when they occurred. A new group is created only if there is no activity for at least five minutes. If a new event occurs after five minutes pass, a new group is added to the issue. The new group includes all the events that occurred, as long as five minutes without activity has passed.
Changing Statuses This section describes what happens to issues when they are created and what happens when a new event must be added to an issue after the issue's status has changed.
New events are created with the New status.
If an event is closed and a new issue occurs, the event is changed to the Reopened status.
If an event is ignored and a new issue occurs, the event does not change its status. However, the system continues to collect information for the event.
114
Zend Server for IBM i
115
Zend Server 5 for IBM i Reference Manual
Page Cache The Zend Page Cache component is used to cache the entire output of PHP scripts, without changing the PHP code. The Zend Page Cache improves PHP application performance by caching the entire output of PHP scripts (HTML, XML, etc.), while still maintaining dynamic capabilities through an elaborate rules system. Rules are configured in the Administration Interface. Page caching extends the concept of caching files and applies it to pages. Caching by page facilitates the ability to eliminate situations where the same file is used in multiple instances, such as when the same file is used to redirect to several pages. When to Cache Pages Pages should be cached when their content is stable and does not require frequent changes. You can cache any PHP generated output including, HTML, XML, and images (if the images are generated by PHP, such as graphs and charts). Compression should be used to cache content such as HTML, XML and plain text, but is not recommended for caching binary output. When Not to Cache Pages Caching is not recommended for files that have constantly changing output, such as clocks, timers and database queries. Compression should not be used for images, PDF files, .exe files, ZIP files or any other compressed binary formats. Note: Zend Page Cache only caches GET and HEAD HTTP requests. To comply with the HTTP RFC, POST requests are never cached. All cached content is stored in a hashed directory structure on disk. The location is defined by the directive zend_pagecache.save_path.
Caching Alternatives Web pages that contain sections that continuously change can also be cached. This partial page caching solution can be accomplished by applying the Data Cache API to the portions of code that do not change. Data caching is an intermediate solution to provide a partial performance boost that can sustain the accuracy of changing content. To find out more about this alternative, go to Data Cache
116
Zend Server for IBM i
Job Queue Component The Jobs approach is used for streamlining offline processing of PHP scripts. It provides the ability to delay execution of “heavy” parts of web applications that originate from direct user interaction with a Web Server. As result it may significantly improve response time and reduce Web Server load. Basically, any authorized PHP script can create a job which will be executed later, separately from a current HTTP request. The job itself is just an additional HTTP request to another PHP script that can be done on the same or different Web Server. In addition, the Jobs component supports SHELL based jobs which can execute any command.
As opposed to “fire and forget” systems,(like cron), the Job Queue is a job management system that provides advanced capabilities such as:
Keeping track of batch jobs, including their status, execution time and output
Different schedule strategies based on time, load, job priorities and dependencies
Run-time statistics
Web-based management GUI
The functional diagram of the Job Queue is shown on the following picture.
The central part of the Job Queue system is the Job Queue daemon. As a standalone process, it serves requests from front-end PHP scripts (through special extension which encapsulates all the protocol details). Such requests may ask to create a new job with specific parameters or to retrieve the state of previously added jobs. To store information about jobs, Job Queue uses a central database. All the database updates (e.g. job creation, deletion, etc) are performed only by
117
Zend Server 5 for IBM i Reference Manual
the Job Queue Daemon. Front-end PHP scripts and management GUI may modify data in the database only through Client Extension API calls which actually send requests to the daemon. The Job Queue may be easily configured to use several dedicated back-end servers which handle HTTP based batch jobs. In this case it performs a type of load balancing by spreading jobs across servers.
118
Zend Server for IBM i
Zend Code Tracing Zend Code Tracing enables real-time execution flow recording in Production Environments. Code Tracing enables deep analysis of PHP execution and flow using drill-down requests related to an Event (Monitoring Rule), or triggered manually. The component focuses on collecting key data points such as:
Application functions and main PHP function calls including function arguments
High-resolution timing and memory usage of execution elements.
Key PHP engine services such as Web server interface calls
The information collection process focuses on only keeping relevant information based on userdefined parameters that trigger events. Each time an event is triggered the information is dumped (kept) for further use. Otherwise, the information will be discarded to preserve disk-space. Events can also be triggered to generate a dump for a specific URL (see Creating a Dump page).
The Trace information is a capture of the Function Tree and enables deep tracing of the functions of the server parameters, including:
Returns
Memory
Time (ms)
Advantages One of the most appealing characteristics of this application is that the performance and memory characteristics have been designed to be suitable for production environments and excellent indepth trace of execution. Other advantages:
In-depth root-cause analysis when event happens. Trace of “exact” request which had the failure (a view back in time)
No need for risky reproduction
Insight into additional PHP subsystems beyond the script itself such as Web Server interface
Technology suitable for development, testing, staging and production
119
Zend Server 5 for IBM i Reference Manual
Zend 5250 Bridge The 5250 Bridge is a PHP based solution for running interactive applications in the i/OS environment. This provides an answer to the challenges faced with directly accessing the 5250 data stream. The 5250 Bridge provides a method for running interactive i/OS based applications through a browser. There are several distinct usages for this solution: 1. Providing a web-based interface to replace the traditional green-screen display – allowing for a wider range of functionality and display options. 2. Creating a web-based version of legacy applications – opening up the functionality to users who are not familiar with the i/OS environment and extending the usage to a wider range of users. 3. Incorporating information from i/OS into integrated applications – providing System Integrators with tools to ensure true integration with data/applications located on i/OS servers.
5250 Predecessor
120
Zend Server for IBM i
How the Zend 5250 Bridge Works The diagram below shows how the 5250 Bridge can be used to access information from a 5250 program and leverage it to either be displayed in a browser-based environment or to populate screen values: 1. PHP sends a 'start session' request to the 5250 Program using the 5250 Bridge. 2. The 5250 Bridge returns a confirmation to PHP that the session has started. 3. The 5250 Bridge sends current screen information in XML format to PHP (e.g. format name, input and output fields and current cursor position). 4. The XML data can be automatically entered into the program or sent on in an html format for user input.
Flow depicting the interaction between the 5250 Bridge, the i/OS server, and PHP
121
Zend Server 5 for IBM i Reference Manual
Overview The Zend 5250 Bridge is a PHP API which offers several modernization options for running interactive (5250) applications in a Web environment. The 5250 Bridge assists developers who are interested in PHP as a strategic Web development platform for their organizations.
The 5250 Bridge is a set of functions that developers can use to import 5250 functionality into a Web-based environment. The 5250 Bridge offers 2 models of operation: 1. 5250 Emulator - Displays your IBM i application in a browser by emulating your application. 2. 5250 Bridge API - Web-enables your application and allows for complete customization options.
The Working with the 5250 Bridge section will help you to decide which mode of operation is suitable for you. Note: In all the cases, the business logic continues to run normally on the IBM i. The options given are for presentation level changes and further in-browser functionality and PHP development. Note: The 5250 Bridge uses the IBM WebFace server which allows the running of interactive (5250) programs in batch mode. IBM WebFace server APIs do not support Workstation IDs. The display device starting with QQF is created and used by the WebFace APIs.
Advantages The following list describes a few key advantages to implementing the 5250 Bridge:
Does not require WebSphere Application Server (WAS), resulting in lower CPW requirements providing the ability to run applications on less expensive machines.
No 5250 workload - use batch processes for green screen programs instead of interactive processes.
No display file source required - works on objects.
Allows access to a variety of IBM i resources that do not currently have an interactive option.
Transfer presentation data only - Only transfers the information displayed on screen, reducing traffic.
122
Zend Server for IBM i
Ability to encapsulate a 5250 program into Web Services - present the application as a Web service to grant access from any client without limitations.
Free single connection for evaluating the 5250 Bridge even after the trial license expires. This provides the ability to create a fully functioning Web based application in PHP based on content currently only accessible from the 5250 emulation.
Extendibility with features only applicable to Web based applications such as Rich-text, sound and images, AJAX, Mashups.
Note: The Zend Server for IBM ir trial license allows creating unlimited interactive (5250) sessions. Once the trial license expires the interactive (5250) sessions will be limited to one at a time. Fully licensed versions permit creating unlimited interactive (5250) sessions.
123
Zend Server 5 for IBM i Reference Manual
Applications The Applications tab is accessed from, Monitor | Applications.
5250 Bridge API Demo Applications The two Demo Applications demonstrate how the 5250 Bridge API can be used to create interactive web-applications for 5250 programs. Clicking one of the demo application links open a new browser Window .The "return to demo page" link displays "The Zend 5250 Bridge Demo Programs" page. For optimized performance open the demo applications in Mozila Firefox (click here to download).
Note: The sample application code is located in: /usr/local/zendsvr/5250/demos. For more information about the Demo Applications and how you can recreate this functionality in your environment see: Analyzing the Demo Applications.
124
Zend Server for IBM i
Working with the Demo Applications Subfile Demo To login, click on the Subfile demo option. You will be directed to a login screen that cannot be edited. Click login to open the demo. You will notice there is a "Disconnect" button, use this button to remove the session when you have finished using the demo. Comparison: If you open the Demo Application in a green screen emulation and in the browser and compare them side by side you will notice that there are a few differences. These differences are not due to technological constraints rather to demonstrate the ability to extend usability beyond copying screens. A web application has more flexible display options such as using a button to get details instead of OPTION 5 and using a popup to display the details instead of moving to another screen each time you enter a new command. These things should be considered when creating a web based version of an I5/OS application to make sure you benefit from an optimal range of advantages.
Behind the Subfile Demo This demo application was written in PHP using the Zend 5250 Bridge Procedural API Functions using functions to organize the code and HTML for the display. The source code for the Demo Applications can be found in /usr/local/zendsvr/5250/demos/subfileExtended. The main file is called index.php. Sample applications can be viewed in a green screen by logging into IBM i. When using your emulator, you can view the original format of the demo application by running the following command in the command area: ADDLIBLE ZENDSVR and CALL ZMI001R.
Extended Subfile Demo The Extended Subfile Demo, shows how you can use the 5250 Bridge API recreate IBM i resources in a web based environment without using the 5250 emulation client look and feel. This like the Subfile Demo, provides a way to extend your IBM i resources to the web and provide a more user friendly application and in addition demonstrates how you can improve the layout using HTML and AJAX.
125
Zend Server 5 for IBM i Reference Manual
Working with the Extended Subfile Demo To login, click on the Extended Subfile demo option. You will be directed to a login screen that cannot be edited. Click login to open the demo. You will notice there is a "Disconnect" button, use this button to remove the session when you have finished using the demo.
Behind the Extended Subfile Demo This demo application was written in PHP using the Zend 5250 Bridge Object Oriented API using classes to organize the code and AJAX to create advanced functionality like replacing language types with flags representing the language and adding pictures to each name. The source code for the Demo Applications can be found in /usr/local/zendsvr/5250/demos/subfileExtended. The main file is called index.php. Sample applications can be viewed in a green screen by logging into IBM i. When using your emulator, you can view the original format of the demo application by running the following command in the command area: ADDLIBLE ZENDSVR and CALL ZMI001R.
126
Zend Server for IBM i
Working with the Zend 5250 Bridge The Zend 5250 Bridge provides two different methods for Web-enabling your PHP applications: 1. Zend 5250 Emulator - Takes the back-end logic of your 5250 application and displays it in a browser format. This is achieved without any work from the developer. 2. Zend 5250 Bridge API - A set of API functions which allow you to use the input and output data in your 5250 application to construct a PHP application which allows complete flexibility and customization options.
Which Method Should you Choose? The method you choose will depend on the amount of time you want to invest in the process, the programming knowledge and skills that you or your programmers possess, and the amount of extra customization and functionality that you would like to add to your application:
Zend 5250 Emulator Use the Zend 5250 Emulator if you:
Need to give users browser access to your 5250 applications and want to invest a minimum amount of development time.
Want to reduce emulator application deployment costs (licences/time).
Want to make small cosmetic changes (colors etc.) to your screens.
Do not know PHP or JavaScript (though a basic knowledge of HTML/CSS is useful if you want to customize the 'look' of your screens.)
Want to test the capabilities of the Bridge.
Plan to frequently change your 5250 Display Files.
5250 Bridge API Use the Zend 5250 Bridge API if you:
Want to make presentation-level changes as well as applying additional display logic
Want to apply complete display-side customization to all or individual screens.
Want to combine several screens into a new view.
Want to remove or filter out content/data for a subset of end-users (e.g. redundant fields).
Have a good knowledge of PHP/HTML/CSS/JavaScript (recommended).
Expect to continue significant development of your RPG 5250 applications and want to minimize Parallel Maintenance considerations.
127
Zend Server 5 for IBM i Reference Manual
Want to pipeline the data coming from the bridge for usage in other, non browser applications (Java, Web Services, others.)
For more information on working with the Zend 5250 Bridge see Zend 5250 Bridge Introduction.
128
Zend Server for IBM i
Zend Server for IBM i 5250 Bridge Settings The 5250 Bridge Settings page is accessed from Server Setup | 5250 Bridge Settings.
The 5250 Bridge Settings page enables you to configure your settings for smooth integration with other current user settings; for instance, language settings and characters, connection type and performance, server time-out, and print screen as XML. The 5250 Bridge Settings tab includes the following windows:
Zend 5250 Bridge
Zend 5250 Bridge Configuration
Zend 5250 Bridge Click the Start service link to begin the service Note: The same function can be invoked from the 5250 Bridge Management Menu (option 7 in the Zend Server for IBM i Service Menu).
Zend 5250 Bridge Configuration The Zend 5250 Bridge Configuration window enables you to integrate with your current user settings:
I/OS EBCDIC Character Code Page (CCSID) - The values are: English, Italian, French, German and Spanish. This setting allows to view 5250 screen special characters in a browser
Persistent Connection - Define the connection type between the 5250 Bridge and your System i server. Click, Yes for a persistent connection and No for the connection to be terminated once the script has run. Persistent connections allow to increase 5250 Bridge server connection-time performance. For more detailed information on persistent connections,.refer to i5-pconnect in the PHP Toolkit section.
Server Time-Out (in microseconds) - The time to wait for a connection to the IBM i server before timing-out. Decreasing the server timer-out allows to increase PHP script overall performance using the 5250 Bridge API. This setting can be set to 0 for V5R4.
Print Screen Image as XML - This can be used by developers to debug their applications by providing an XML version of the 5250 screen image. Clicking Yes, will add an additional field for you to specify a path for saving the file containing screen image information in XML format. After changing the settings, click Save to apply changes.
129
Zend Server 5 for IBM i Reference Manual
Working with the Zend Server 5250 Emulator The Zend 5250 Emulator provides browser access to IBM i resources and applications equivalent to an IBM® 5250 terminal. This does not require any work from the developers or end users. However, customization options for the developer are limited to presentation-level via CSS files. This method is suitable for users who want to test the capabilities of the Bridge or simply need to give users browser access to their applications without having to deploy telnet or terminal client applications.
How it Works The Emulator application automatically displays your 5250 applications in a browser. It does so by collecting screen information from your 5250 application screens and displaying this information in a browser, based on the settings configured in one of three included CSS template files. By default, the Emulator application was designed to render pages in a way which resembles the original 5250 green screens in order to make the transition easy for the users. The look and layout of the application is controlled by three CSS files included in the Emulator. In order to edit the basic layout and look of your screens, you can edit one of these CSS files, which will apply changes to all screens in your application.
130
Zend Server for IBM i
Connecting to your Emulated Application By installing the Zend Server for IBM i Package (which includes the Zend 5250 Emulator) onto your server, you have already completed the process of Web-enabling your application. You now simply need to browse to your application in order to view it. The Zend 5250 Emulator takes the input and output fields in your 5250 application and converts them into HTML/CSS based screens. Editing the designated CSS file provided with the Zend 5250 Emulator lets you edit the style and layout of the application.
To connect to your emulated application: 1. Access the emulator through the Applications tab, -orBrowse to: "; // End the 5250 session zend_5250_disconnect($bridge); ?>
Notes: The Zend 5250 Bridge without a valid Zend Server for IBM i license will enable a single connection at a time. Therefore, ensure you close the 5250 Bridge connection at the end of a program by using the zend_5250_disconnect() function.
Running this code will launch your IBM i connection screen and display the array structure information for this screen as follows (the following information is only partial):
Array ( [0] => Array ( [id] => 0 [row] => 1 [column] => 23 [length] => 33 [value] => [color] => 3 ) [1] => Array ( [id] => 1 [row] => 2 [column] => 48 [length] => 19 [value] => System [color] => 1 ) [2] => Array (
Sign On
. . . . . :
145
Zend Server 5 for IBM i Reference Manual
[id] => 2 [row] => 2 [column] => 70 [length] => 8 [value] => I5QA2 [color] => 1 ) [3] => Array ( [id] => 3 [row] => 3 [column] => 48 [length] => 19 [value] => Subsystem . . . . [color] => 1 ) [4] => Array ( [id] => 4 [row] => 3 [column] => 70 [length] => 10 [value] => QINTER [color] => 1 ) [5] => Array ( [id] => 5 [row] => 4 [column] => 48 [length] => 19 [value] => Display . . . . . [color] => 1 ) [6] => Array ( [id] => 6 [row] => 4 [column] => 70 [length] => 10 [value] => QQF048FE62 [color] => 1 ) [7] => Array ( [id] => 7 [row] => 6 [column] => 17 [length] => 33 [value] => User . . . . . . [color] => 1 ) [8] => Array ( [id] => 8 [row] => 7 [column] => 17 [length] => 33 [value] => Password . . . . [color] => 1 ) [9] => Array ( [id] => 9 [row] => 8 [column] => 17 [length] => 33 [value] => Program/procedure [color] => 1 ) [10] => Array
146
:
:
. . . . . . . .
. . . . . . . .
. . . . . . . .
Zend Server for IBM i
( [id] => 10 [row] => 9 [column] => 17 [length] => 33 [value] => Menu [color] => 1
. . . . . . . . . . . . . .
) [11] => Array ( [id] => 11 [row] => 10 [column] => 17 [length] => 33 [value] => Current library . . . . . . . . . [color] => 1 ) [12] => Array ( [id] => 12 [row] => 24 [column] => 40 [length] => 40 [value] => (C) COPYRIGHT IBM CORP. 1980, 2005. [color] => 3 ) )
Using the array structure information displayed for the input and output fields, you can then write further code utilizing the Zend 5250 Bridge API. You can either create HTML browser based screens for user input, or automatically continue running the 5250 application by setting input field values and sending the function key actions.
You must then get array structure information for the next screen in order to continue developing.
For example, the following code will start a 5250 sess5sion, log you in to the IBM i system and display array structure information for the next screen: "; print_r($outputFields); echo "
"; // Print the input fields information
147
Zend Server 5 for IBM i Reference Manual
echo "
"; print_r($inputFields); echo "
"; // End the 5250 session zend_5250_disconnect($bridge); ?>
You will need to repeat this process to get and use field array structure information for each 5250 screen in your PHP application.
There is an additional way a developer can identify the 5250 screen field type (input/output) and field id. Run an interactive (5250) application using the 5250 Bridge Emulator program. Place the cursor on a screen location where you want to know the screen type and screen id.
For example, in the screen below the cursor is placed on '2.Office tasks' location and the 5250 Bridge emulator program shows that this is an output field and its id is 7. FLD_06_007. where 06 is a field row and 007 is a field starting colum7.
Identifying 5250 Screen Field Types
148
Zend Server for IBM i
See the 5250 Demo Applications included with the 5250 Bridge for further examples on writing applications using the 5250 Bridge API. For example, to see the code for the 'subfile' demo application go to: /usr/local/zend/5250/demos/subfile/index.php. For more sample code, refer to Zend 5250 Bridge Use Case Examples. Note: The 5250 Bridge installation includes two Java Script files to catch function key clicks. You can find more information in the Zend installation folder: /usr/local/zendsvr/5250/demos/ JSfunctionKeyListener on your System i server.
149
Zend Server 5 for IBM i Reference Manual
Troubleshooting the Zend 5250 Bridge Problem
Solution
The Zend 5250 Bridge environment is
1. In the Zend 5250 Management Menu
occasionally 'overloaded'.
(accessed by running the command "GO ZENDSVR/ZSMENU" in your IBM i emulation screen) select Option 4 - Reset 5250 Bridge environment. 2. End the ZBRDG5250 job in the ZENDSVR Subsystem. 3. Clear your Cookies.
The 5250 Bridge does not get the correct screen information.
1. Increase the Server Time-Out in the Server Setup ->5250 Bridge Tab (http://i_server:10088/ZendServer/, Integration menu) 2. Open your 5250 Bridge Configuration file (Brdg5250.ini - located in /usr/local/ZendSrv/5250/etc/Brdg5250.ini) and increase your system timeout in the 'ReadTimeoutMicro' directive.
150
Zend Server for IBM i
FAQ What is the 5250 Bridge?
The 5250 Bridge is a set of APIs for creating interactive IBM i based applications that run through a browser.
Does the 5250 Bridge generate
The 5250 Bridge does not generate HTML.
HTML?
The 5250 Bridge API offers a number of functions/classes for PHP developers to grab fields and strings from an interactive (5250) program and wrap them into real web applications. This way you can seamlessly integrate output of green screen applications into your PHP Web application without the need to rewrite the business logic and directly access the database. Alternatively you can use the 5250 Bridge API to directly access the database and create completely new Web applications.
What product do I need to install in
The 5520 Bridge API is an integrated part of Zend
order to get the 5250 Bridge API?
Server for IBM i
What IBM i Version does the 5250
The 5250 Bridge runs on V5R4, or later and utilizes
Bridge Support?
5250 CPW interactive processes.
How does the 5250 Bridge API
The basic process is as follows:
work from the PHP script?
1. PHP sends a 'start session' request to the 5250 Program using the 5250 Bridge API. 2. The 5250 Bridge API returns a confirmation to PHP that the interactive program session has started. 3. The 5250 Bridge API sends current screen information in XML format to PHP (e.g. input and output fields, their attributes and cursor position). 4. PHP sends input values and function key actions to the 5250 Bridge API.
How many concurrent (5250)
The 5250 Bridge can handle an unlimited amount of
sessions does the 5250 Bridge
concurrent 5250 sessions. Only when using an
allow to open?
unlicensed version or trial license expires will the number of concurrent connections be limited to one. This single connection is enough for a developer to be able to create a Web application utilizing the 5250 Bridge API.
151
Zend Server 5 for IBM i Reference Manual
Are 5250 sessions opened by the
The 5250 Bridge uses the IBM WebFace server which
5250 Bridge using IBM i interactive
allows the running of interactive (5250) programs in
feature?
batch mode.
Does the 5250 Bridge support
The 5250 Bridge utilizes the IBM WebFace server
Workstation IDs?
APIs, which do not support Workstation IDs. The display device starting with QQF is created and used by the WebFace APIs.
Is there support for IBM i function
The 5250 Bridge installation includes two Javascript
keys such as F3, F12, etc?
files, which allow the catching of function key clicks.
(Bridge API)
You can find more information about function keys in the Zend installation folder /usr/local/ZendSVR/5250/demos/JSfunctionKeyListener on your IBM i server.
Why are the demo applications
The demo applications run on default settings. There
slow?
are several optimizations that can be done to improve performance: Decrease the server time-out in the 5250 Tab. This change allows the increase of PHP script overall performance. This setting is set to 0 in V5R4. Set the "Persistent Connection" to "Yes" in the 5250 Tab. The Persistent connections allow the increasing of 5250 Bridge server connection-time performance.
Do I need to know OO
The 5250 Bridge API has two types of interfaces:
programming?
classes and procedural. RPG developers who are not familiar with OO can utilize the 5250 Bridge procedural functions (similar to RPG/CL). Java developers who are familiar with OO can utilize 5250 Bridge classes.
Can I incorporate stylesheets into
You can use the demo application code as a base to
demo program screens and turn
create Web applications utilizing the 5250 Bridge API.
fields into selection lists or radio
You can enrich your browser applications with Web
buttons?
features such as Rich-text, sound and images, AJAX and Mashups.
152
Zend Server for IBM i
153
Zend Server 5 for IBM i Reference Manual
Reference Information This section contains reference information for PHP developers. Here you will find information about using the Java Bridge, the extensions included in this release and other system-related information.
The list of extensions provides an overview of all the extensions that are included and their status (On, Off, Disabled). A description of what each status means can be found in PHP Extensions. In this section:
154
Java Bridge Use Cases
Adding Extensions
Compiling PHP Extensions
Info Messages
Zend Server for IBM i
Java Bridge Use Cases This section describes some of the common uses for the Java Bridge. The usage scenarios and examples discussed here provide a framework for the Java Bridge’s uses, rather than a complete picture. Real world experience indicates that companies are finding more and more applications for the Java Bridge, beyond what was initially anticipated.
Usage Scenarios There are two usage scenarios that describe the most common applications for the PHP/Java Bridge:
Integration with Existing Java Infrastructure - PHP is a fully featured scripting language engineered to cover virtually all of an enterprise’s requirements. At the same time, many enterprises have a long history of application development in Java. The Java Bridge enables enterprises to continue to use their Java infrastructure - applications, databases, business logic and various Java servers (WebLogic, JBoss, Oracle Application Server, etc.).
Accessing Java Language and Architecture - Some enterprises require the full set of PHP capabilities, yet have a specific need for select Java based applications. SIP signaling in the communications industry or JDBC for creating connectivity to SQL databases are two examples of impressive, industry specific products. The Java Bridge enables enterprises to adopt a PHP standard and to use their preferred Java based applications.
Activities This section describes two sample activities that indicate some of what you can do with the PHP/Java Bridge. In the sample activities, it is important to differentiate between Java and J2EE. The difference will impact on architecture and in turn, on the script code. The important differences are:
Java is a programming language. Java applications created in Java for the enterprise are not bound to a specific framework. Therefore, it is possible and perhaps preferable for an enterprise to relocate code libraries to the server that runs Zend Server for IBM i .
J2EE is a structured framework for application scripts developed for J2EE. It is preferable that J2EE servers be left intact.
155
Zend Server 5 for IBM i Reference Manual
Example 1: A Case Study in Java Bridge Performance (Java) The Forever Times newspaper maintains a PHP-based website - let’s call it ForeverOnline.com. The newspaper has been searching for a real-time Stock Ticker application to add to their already successful and heavily visited website. The Forever Times Newspaper feels that real-time financial information is the one thing their website is lacking. Forever Times believes they have found exactly the Stock Ticker application they need. The application provides up-to-date quotations from all the major markets, currency rates, and even links to some of the local exchanges. However, the application is written in Java and uses existing Java libraries. Forever Times realizes that a PHP-based Web implementation that handles Java requests - a Java Bridge - is their best bet. At the same time, they are concerned that the performance of their Website remains optimal. To Forever Times’ horror, in testing the new application, they find that loading the site with user-requests for the Stock Ticker slows down the performance of the whole website. The following code example illustrates how the Java Bridge applies to this business scenario and others like it: Example: // create Java object $stock = new Java("com.ticker.JavaStock"); // call the object $news = $stock->get_news($_GET['ticker']); // display results foreach($news as $news_item) { print "$news_item
\n"; } ?>
The example code can be understood as follows:
The code example is written in PHP and forms part of a PHP Web application.
The PHP code creates the Java object-"com.ticker.JavaStock"-which is the PHP proxy.
Requests come into the PHP based Website - ForeverOnline.com - which then references the Stock Ticker application.
Stock Ticker references a custom object- get_news-in the JVM library. This is all in native Java.
The PHP code then outputs the results on the Website.
As opposed to a typical Java Bridge Implementation, the Zend Server for IBM i Java Bridge implementation addresses performance issues through the Java Bridge architecture. Implementing the Java Bridge is a way to address scalability issues by using the Java Bridge to handle all communication in a single JVM instance, instead of in several instances.
156
Zend Server for IBM i
Note: While the single JVM constitutes a single point of failure, the fact is, Zend’s PHP-Java connection is the most robust on the market. Failures in systems of this type generally tend to occur when the Java Server is overloaded, rather than as a result of glitches in the applications. Zend Server for IBM i ’s system architecture insures performance by diminishing overhead. However, in the event of failure, the Java Bridge supports a restart feature that makes monitoring the status of the Java Server and restarting quick and simple. One last point: if the failure was caused by a glitch in the application, the same thing would most likely occur in each of the JVMs in the non-Zend system!
Example 2: A Case Study in Management Integration (J2EE) A company called FlowerPwr.com sells flowers over the Internet. They are a successful East Coast-based firm that has an aggressive management profile. They are currently in the process of acquiring a West Coast competitor - let’s call it Yourflowers.com - that provides a similar service. FlowerPwr.com has its own website: Its various enterprise applications are written in PHP. Yourflowers.com also has its own Website: However, all its applications are Java-based and were developed for J2EE. They have their own J2EE application server. FlowerPwr.com needs to begin operating as an integrated commercial entity as soon as possible, in a way that conceals the fact that the companies have merged. Using the Java Bridge, FlowerPwr.com can create a common portal in PHP. The company can leave Java up and running and take full advantage of their acquisition’s existing Java services. FlowerPwr.com can do this over an existing portal using PHP. The following code example illustrates how the Java Bridge can apply to this business scenario and others like it: Example: // EJB configuration for JBoss. Other servers may need other settings. // Note that CLASSPATH should contain these classes $envt = array( "java.naming.factory.initial" => "org.jnp.interfaces.NamingContextFactory", "java.naming.factory.url.pkgs" => "org.jboss.naming:org.jnp.interfaces", "java.naming.provider.url" => " jnp://yourflowers.com:1099"); $ctx = new Java("javax.naming.InitialContext", $envt); // Try to find the object $obj = $ctx->lookup("YourflowersBean"); // here we find an object - no error handling in this example $rmi = new Java("javax.rmi.PortableRemoteObject"); $home = $rmi->narrow($obj, new Java("com.yourflowers.StoreHome")); $store = $home->create(); // add an order to the bean $store->place_order($_GET['client_id'], $_GET['item_id']); print "Order placed.
Current shopping cart:
"; // get shopping cart data from the bean $cart = $store->get_cart($_GET['client_id']); foreach($cart as $item) {
157
Zend Server 5 for IBM i Reference Manual
print "$item['name']: $item['count'] at $item['price']
\n"; } // release the object $store->remove(); ?>
The example code can be understood as follows: 1. The code example is written in PHP and forms part of a PHP Web application. 2. The PHP application first initializes an operation with the EJB, located at a specific URL that has the name:"//yourflowers.com:1099." 3. The code then specifies the bean-YourflowersBean-that the application will look for. 4. Next, the bean object is returned from the EJB server. 5. The application then calls methods-in this case, the Java application includes two functions:
place_order receiving two numbers - client ID and the item ID to add to shopping cart
get_cart receiving one number - client ID and returning the list of the items placed in the shopping cart so far.
After script execution, the referenced class may be disposed.
158
Zend Server for IBM i
PHP Extension List Zend Server for IBM i, supports two PHP versions, PHP 5.2 and PHP 5.3. Each PHP version has its own list of extensions as follows:
Zend Server for IBM i PHP 5.2 Extensions Zend Server for IBM i PHP 5.3 Extensions
159
Zend Server 5 for IBM i Reference Manual
Zend Server Extension List - PHP 5.2 Common Extensions Common extensions are installed and enabled by default in typical installations
Extension Status
Description Arbitrary precision mathematics functions based on the bcmatch (Binary
Bcmath
Enabled
bz2
Enabled
calendar
Enabled
ctype
Enabled
curl
Enabled
date
Built-in
dom
Built-in
exif
Enabled Enables access to image EXIF (Exchangeable Image File Format) meta data
filter
Built-in
ftp
Enabled Provides low-level client access to FTP (File Transfer Protocol) servers
gd
Enabled
gettext
Enabled
hash
Built-in
i5comm
Enabled
iconv
Enabled Enables conversion between different character sets using the iconv library
imap
Enabled Provides mail and news access through the IMAP, POP3 and NNTP protocols
intl
Enabled
160
Calculator) library The bzip2 functions are used to transparently read and write bzip2 (.bz2) compressed files and streams The calendar extension provides functions that simplify conversion between different calendar formats Character Classifications - Checks whether a character or string falls into a certain character class according to the current locale Enables you to connect to and communicate with different types of servers using various protocols - for example HTTP and FTP Enables various date and time related functions that can handle retrieving the time, date formatting and more Enables operating on an XML document using the Document Object Model (DOM) API
Provides a set of functions for validating and filtering data coming from insecure sources, such as user inputs
Enables creation, manipulation and streaming of images and graphics in various formats Provides a set of functions that allow internationalization of PHP applications through the GNU gettext API Enables direct or incremental processing of arbitrary length messages using a variety of hashing algorithms Provides access to all IBM i system resources such as RPG/COBOL/CL programs, database files / tables, spooled files, data queue and more
Provides Unicode and global localization support to PHP applications using the ICU library
Zend Server for IBM i
Extension Status
Description
json
Enabled Implements the JavaScript Object Notation (JSON) data-interchange format
ldap
Enabled
libxml
Built-in Provides basic API and infrastructure for other XML processing extensions
mbstring
Enabled
mcrypt
Enabled Provides support for multiple encryption algorithms using the mcrypt library
Provides access to LDAP (Lightweight Directory Access Protocol) based directory servers; Based on the OpenLDAP library
Enables manipulation of strings encoded in multi-byte character encoding schemes
Provides support for multiple hashing algorithms using the mhash library. Can be mhash
Enabled used to create checksums, message digests, message authentication codes, and more
mime_magic Enabled Eanbles automatic MIME-type detection based on various patterns in files Provides legacy access to MySQL database servers. For new applications it is
mysql
Enabled
mysqli
Enabled
openssl
Built-in
pcre
Built-in
pdo
Built-in
pdo_mysql
Enabled
pdo_oci
Enabled
pdo_pgsql
Enabled
pdo_sqlite
Built-in
pgsql
Enabled Provides access to PostgreSQL database servers
posix
Enabled
reflection
Built-in
session
Built-in Enables data persistence between consecutive requests of the same user session
recommended to use the 'mysqli' extension MySQL Improved - Provides access to MySQL database servers. Enables the functionality provided by MySQL 4.1 and above This module utilizes the OpenSSL library for generation and verification of signatures and for encrypting and decrypting data and streams Provides a set of functions for string matching and manipulation based on Perl Compatible Regular Expressions syntax Base PDO (PHP Data Objects) Driver - Defines a lightweight, consistent interface for accessing databases in PHP PDO (PHP Data Objects) driver that enable access from PHP to MySQL database servers PDO (PHP Data Objects) driver that enable access from PHP to Oracle database servers using the OCI library PDO (PHP Data Objects) driver that enable access from PHP to PostgreSQL database servers PDO (PHP Data Objects) driver that enable access from PHP to SQLite database files
Contains an interface to functions defined in the IEEE 1003.1 (POSIX.1) standards document which are not accessible through other means Adds the ability to reverse-engineer classes, interfaces, functions and methods as well as extensions
161
Zend Server 5 for IBM i Reference Manual
Extension Status
Description The SimpleXML extension provides a very simple and easily usable toolset to
simplexml
Built-in convert XML to an object that can be processed with normal property selectors and array iterators
soap
Enabled The SOAP extension can be used to implement SOAP Servers and Clients
sockets
Enabled
spl
Built-in
sqlite
Enabled
standard
Built-in Standard PHP functions
tidy
Enabled
The socket extension implements a set of low-level socket communication functions, providing the possibility to act as a socket server as well as a client SPL is a collection of interfaces and classes that can be used to solve standard problems Enables usage of the SQLite Embeddable SQL Database Engine. Can be used for SQL database access without running a separate RDBMS process
Tidy HTML Clean and Repair - enables you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree The tokenizer functions provide an interface to the PHP tokenizer embedded in
tokenizer
Enabled
the Zend Engine. Using these functions you may write your own PHP source analyzing or modification tools without having to deal with the language specification at the lexical level
xml
Built-in
xmlreader
Enabled
xmlwriter
Enabled
xsl
Enabled
zip
Enabled
Enables the creation of event-based XML document parsers using the SAX XML interface The XMLReader extension is an XML Pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way. Provides a non-cached, forward-only writer for generating streams or files containing XML data in an efficient manner The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library ZIP Archives - Enables you to transparently read ZIP compressed archives and the files inside them Enables you to transparently read and write gzip (.gz) compressed files, through
zlib
Built-in versions of most of the filesystem functions which work with gzip-compressed files
162
Zend Server for IBM i
Extra / Additional Extensions Extra extensions are shipped by Zend and can easily be installed but are not installed by default in typical installations
Extension Status
Description Allows retrieval of information regarding many different file types. This
fileinfo
Disabled information includes file type and encoding, as well as more specific information such as dimensions, quality or length These functions allow you to work with arbitrary-length integers using the GNU
gmp
Disabled
imagick
Enabled Enables image creation and manipulation using the ImageMagick API
memcache
Disabled
ming
Disabled
mssql
Disabled
odbc
Disabled Provides access to several database servers through the Unified ODBC interface
MP library
Provides access to memcached - a highly efficient memory based caching daemon Provides a set of functions that can be used to create SWF ("Flash") format animations; Based on the open-source Ming library Provides access to MS SQL Server database; Based on the open-source FreeTDS library
Process Control Functions - Process Control support in PHP implements the Unix pcntl
Disabled style of process creation, program execution, signal handling and process termination PDO (PHP Data Objects) driver that enable access from PHP to MSSQL and other
pdo_dblib
Disabled
pdo_odbc
Disabled databases through ODBC drivers or through the IBM DB2 Call Level Interface
databases accessible through the FreeDTS interface PDO (PHP Data Objects) driver that enable access from PHP to different (DB2 CLI) library
pspell
Enabled
shmop
Disabled
Provides spell checking and dictionary management functionality based on the pspell library Shared Memory - Shmop is an easy-to-use set of functions that allows PHP to read, write, create and delete Unix shared memory segments Enables System V messages support - The messaging functions may be used to
sysvmsg
Disabled
send and receive messages to/from other processes. They provide a simple and effective means of exchanging data between processes, without the need for setting up an alternative using Unix domain sockets Enables System V semaphore support - Semaphores may be used to provide
sysvsem
Disabled exclusive access to resources on the current machine, or to limit the number of processes that may simultaneously use a resource
163
Zend Server 5 for IBM i Reference Manual
Extension Status
Description Enables System V shared memory support - Shared memory may be used to
sysvshm
Disabled
wddx
Disabled
xmlrpc
Disabled Provides a set of functions that can be used to write XML-RPC servers and clients
provide access to global variables WDDX (Web Distributed Data Exchange) - These functions are intended for work with the WDDX data exchange format
Standalone Extensions Standalone extensions are provided by Zend but are not included in any of the meta-packages / categories above.
Extension Status
Description Provides functions that enable you to access the IBM DB2 Universal Database,
ibm_db2
Enabled
pdo_ibm
Enabled PDO (PHP Data Objects) driver that enable access from PHP to IBM databases
164
IBM Cloudscape, and Apache Derby databases using the DB2 Call Level Interface
Zend Server for IBM i
Zend Server Extension List - PHP 5.3 Common Extensions Common extensions are installed and enabled by default in typical installations
Extension Status
Description Arbitrary precision mathematics functions based on the bcmatch (Binary
bcmath
Enabled
bz2
Enabled
calendar
Enabled
Core
Built-in Core PHP functionality
Ctype
Enabled
Curl
Enabled
Date
Built-in
Dom
Built-in
Ereg
Built-in
Exif
Enabled Enables access to image EXIF (Exchangeable Image File Format) meta data
Calculator) library The bzip2 functions are used to transparently read and write bzip2 (.bz2) compressed files and streams The calendar extension provides functions that simplify conversion between different calendar formats
Character Classifications - Checks whether a character or string falls into a certain character class according to the current locale Enables you to connect to and communicate with different types of servers using various protocols - for example HTTP and FTP Enables various date and time related functions that can handle retrieving the time, date formatting and more Enables operating on an XML document using the Document Object Model (DOM) API Provides a set of string pattern matching functions using POSIX extended regular expressions.
Allows retrieval of information regarding many different file types. This fileinfo
Enabled information includes file type and encoding, as well as more specific information such as dimensions, quality or length Provides a set of functions for validating and filtering data coming from insecure
Filter
Built-in
ftp
Enabled Provides low-level client access to FTP (File Transfer Protocol) servers
Gd
Enabled
gettext
Enabled
Hash
Built-in
sources, such as user inputs
Enables creation, manipulation and streaming of images and graphics in various formats Provides a set of functions that allow internationalization of PHP applications through the GNU gettext API Enables direct or incremental processing of arbitrary length messages using a variety of hashing algorithms
165
Zend Server 5 for IBM i Reference Manual
Extension Status
Description Provides access to all IBM i system resources such as RPG/COBOL/CL programs,
i5comm
Enabled
Iconv
Enabled Enables conversion between different character sets using the iconv library
Imap
Enabled Provides mail and news access through the IMAP, POP3 and NNTP protocols
Intl
Enabled
Json
Enabled Implements the JavaScript Object Notation (JSON) data-interchange format
Ldap
Enabled
libxml
Built-in Provides basic API and infrastructure for other XML processing extensions
mbstring
Enabled
mcrypt
Enabled Provides support for multiple encryption algorithms using the mcrypt library
mysql
Enabled
mysqli
Enabled
openssl
Built-in
Pcre
Built-in
Pdo
Built-in
pdo_mysql
Enabled
pdo_oci
Enabled
pdo_pgsql
Enabled
pdo_sqlite
Built-in
Pgsql
Enabled Provides access to PostgreSQL database servers
Phar
Enabled Allows running of complete PHP applications out of .phar package files
Posix
Enabled
166
database files / tables, spooled files, data queue and more
Provides Unicode and global localization support to PHP applications using the ICU library
Provides access to LDAP (Lightweight Directory Access Protocol) based directory servers; Based on the OpenLDAP library
Enables manipulation of strings encoded in multi-byte character encoding schemes
Provides legacy access to MySQL database servers. For new applications it is recommended to use the 'mysqli' extension MySQL Improved - Provides access to MySQL database servers. Enables the functionality provided by MySQL 4.1 and above This module utilizes the OpenSSL library for generation and verification of signatures and for encrypting and decrypting data and streams Provides a set of functions for string matching and manipulation based on Perl Compatible Regular Expressions syntax Base PDO (PHP Data Objects) Driver - Defines a lightweight, consistent interface for accessing databases in PHP PDO (PHP Data Objects) driver that enable access from PHP to MySQL database servers PDO (PHP Data Objects) driver that enable access from PHP to Oracle database servers using the OCI library PDO (PHP Data Objects) driver that enable access from PHP to PostgreSQL database servers PDO (PHP Data Objects) driver that enable access from PHP to SQLite database files
Contains an interface to functions defined in the IEEE 1003.1 (POSIX.1) standards document which are not accessible through other means
Zend Server for IBM i
Extension Status
Description Adds the ability to reverse-engineer classes, interfaces, functions and methods as
reflection
Built-in
session
Built-in Enables data persistence between consecutive requests of the same user session
well as extensions
The SimpleXML extension provides a very simple and easily usable toolset to simplexml
Built-in convert XML to an object that can be processed with normal property selectors and array iterators
Soap
Enabled The SOAP extension can be used to implement SOAP Servers and Clients
sockets
Enabled
Spl
Built-in
Sqlite
Enabled
standard
Built-in Standard PHP functions
Tidy
Enabled
The socket extension implements a set of low-level socket communication functions, providing the possibility to act as a socket server as well as a client SPL is a collection of interfaces and classes that can be used to solve standard problems Enables usage of the SQLite Embeddable SQL Database Engine. Can be used for SQL database access without running a separate RDBMS process
Tidy HTML Clean and Repair - enables you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree The tokenizer functions provide an interface to the PHP tokenizer embedded in
tokenizer
Enabled
the Zend Engine. Using these functions you may write your own PHP source analyzing or modification tools without having to deal with the language specification at the lexical level Enables the creation of event-based XML document parsers using the SAX XML
Xml
Built-in
xmlreader
Enabled
xmlwriter
Enabled
Xsl
Enabled
Zip
Enabled
Zlib
Built-in versions of most of the filesystem functions which work with gzip-compressed
interface The XMLReader extension is an XML Pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way. Provides a non-cached, forward-only writer for generating streams or files containing XML data in an efficient manner The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library ZIP Archives - Enables you to transparently read ZIP compressed archives and the files inside them Enables you to transparently read and write gzip (.gz) compressed files, through files
167
Zend Server 5 for IBM i Reference Manual
Extra / Additional Extensions Extra extensions are shipped by Zend and can easily be installed but are not installed by default in typical installations
Extension Status
Description These functions allow you to work with arbitrary-length integers using the GNU
gmp
Disabled
imagick
Enabled Enables image creation and manipulation using the ImageMagick API
memcache
Disabled
mssql
Disabled
odbc
Disabled Provides access to several database servers through the Unified ODBC interface
pcntl
Disabled style of process creation, program execution, signal handling and process
MP library
Provides access to memcached - a highly efficient memory based caching daemon Provides access to MS SQL Server database; Based on the open-source FreeTDS library
Process Control Functions - Process Control support in PHP implements the Unix termination pdo_dblib
Disabled
PDO (PHP Data Objects) driver that enable access from PHP to MSSQL and other databases accessible through the FreeDTS interface PDO (PHP Data Objects) driver that enable access from PHP to different
pdo_odbc
Disabled databases through ODBC drivers or through the IBM DB2 Call Level Interface (DB2 CLI) library
pspell
Enabled
shmop
Disabled
Provides spell checking and dictionary management functionality based on the pspell library Shared Memory - Shmop is an easy-to-use set of functions that allows PHP to read, write, create and delete Unix shared memory segments Enables System V messages support - The messaging functions may be used to
sysvmsg
Disabled
send and receive messages to/from other processes. They provide a simple and effective means of exchanging data between processes, without the need for setting up an alternative using Unix domain sockets Enables System V semaphore support - Semaphores may be used to provide
sysvsem
Disabled exclusive access to resources on the current machine, or to limit the number of processes that may simultaneously use a resource Enables System V shared memory support - Shared memory may be used to
sysvshm
Disabled
wddx
Disabled
xmlrpc
Disabled Provides a set of functions that can be used to write XML-RPC servers and clients
168
provide access to global variables WDDX (Web Distributed Data Exchange) - These functions are intended for work with the WDDX data exchange format
Zend Server for IBM i
Standalone Extensions Standalone extensions are provided by Zend but are not included in any of the meta-packages / categories above.
Extension Status
Description Provides functions that enable you to access the IBM DB2 Universal Database,
ibm_db2
Enabled
pdo_ibm
Enabled PDO (PHP Data Objects) driver that enable access from PHP to IBM databases
IBM Cloudscape, and Apache Derby databases using the DB2 Call Level Interface
169
Zend Server 5 for IBM i Reference Manual
Adding Extensions This section includes information for the following Operating Systems:
Zend Server on UNIX/Linux
Zend Server Community Edition on UNIX/Linux/Mac
Zend Server for IBM i
Zend Server for IBM i users can benefit from extension management capabilities for third party extensions as well as for Zend Extensions. This enables users to load and unload all extensions directly from the Zend Server for IBM i Extensions page. Important: The newly added extensions will be visible in the Administration Interface's Extensions page however, the directive configuration option will not be active and directives belonging to the extension have to be configured directly from the php.ini file. Disclaimer: Zend Technologies does not provide support for third party products, including extensions. Therefore, if an issue for support arises, please remove all third party extensions by commenting out the reference to them in your php.ini before referring to the Support Center http://www.zend.com/en/support-center/. There are two types of extensions: PHP extensions and Zend extensions. The extension provider should supply information regarding the extension type (Zend or PHP). Make sure to also check the provider's documentation for possible compatibility issues, PHP version compatibility and any other additional configurations that may be required.
To add Zend extensions: 1. Download the extension Note: Zend Server for IBM i for IBM i - AIX Unix/Linux extensions end with the .so suffix. 2. Place the extension in your extensions directory. To locate the extensions directory, open the Administration Interface to Monitor | PHP Info and check the value for the directive extension_dir=. By default, your extensions directory is located in:
";
/* 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 "
Error number: ".$error["num"]; echo "
Error category: ".$error["cat"]; echo "
Error message: ".$ error ["msg"]; echo "
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. */
276
API Reference
/* Make it available for another script. */ $ret = i5_close($conn); if($ret){ echo " I5 disconnected"; } else { $ret = i5_errormsg($conn); }
Example - Private Connection "; } 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; } } } ?>
Connection Options:
I5_OPTIONS_IDLE_TIMEOUT - sets the time ( in seconds) to raise an event when the connection can be closed by another connection request (i5_connect or i5_pconnect). If this option is not used the connection job will remain open.
I5_OPTIONS_PRIVATE_CONNECTION - Set the ID of the persistent connection to reuse.
I5_OPTIONS_JOBNAME - job name (machine name by default).
277
Zend Server 5 for IBM i Reference Manual
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
i5_pclose bool i5_close([resource connection]).
Description: Closes the persistent connection to i5/OS server..
Return Values: Boolean success value.
Arguments:
connection - Result of i5_pconnect
Example: /* Basic connection to i5/OS */ $conn = i5_pconnect("("i.2.3.4","USER","PWD") if ($conn) { echo "Connection succeeds
"; [treatments...] $closing = i5_pclose($conn); if ($closing) { echo "Disconnection succeeds"; } }
278
API Reference
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);
i5_close bool i5_close([resource connection]).
Description: Closes connection to AS/400 server.
Return Values: Boolean success value.
Arguments: connection - Result of i5_connect
i5_adopt_authority bool i5_adopt_authority(string username, string password, [resource connection]).
Description: Changes authority of the connection to a specific user. All actions will be executed as this user from now on.
Return Values: Boolean success value.
Arguments: •
username - Name of the user to change to
•
password - Password for the user
•
connection - Connection - result of i5_connect
279
Zend Server 5 for IBM i Reference Manual
i5_error bool i5_error([resource connection]).
Description: Retrieves error information for last action that was executed.
Return Values: If there was no error, returns false. Otherwise, returns an array with the following elements:
•
0 - error number, as in i5_errno().
•
1 - error category.
•
2 - error message, as in i5_errmsg().
•
3 - detailed description of the error.
Arguments: connection - Connection - result of i5_connect
i5_errormsg string i5_errormsg([resource connection]).
280
Description: Gets error message for last executed action.
Return Values: Error message string.
Arguments: connection - Connection - result of i5_connect.
API Reference
CL Calls i5_command bool i5_command(string command[, array inputs, array outputs, resource connection]).
Description: Calls CL command.
Return Values: Boolean success value.
Arguments: •
inputs - Array of name => value parts, name describing the call input parameters. Names should match i5 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. Note: The output parameter is required if the input parameter is specified.
•
outputs - Array which describes output parameters of the command. If not provided, no output parameters are defined. Key of the array defined i5 cl command parameter name. "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 parameter or array; it should have 2 elements:
•
A php variable name to accept the parameter.
•
Description of the parameter Note: The input parameter is required if the output parameter is specified.
•
connection - Connection - result of i5_connect.
Example: i5_command("rtvjoba", array(), array("curlib" => "curl",. "user"=>"user",. "usrlibl" => "userlib",. "syslibl" => array("syslib", "char(165)"), . ). );. print "User : $user
" ;. print "User library : $userlib
" ;. print "System libs list : $syslib
" ;. print "Current library : $curl
" ;.
281
Zend Server 5 for IBM i Reference Manual
Program Calls i5_program_prepare resource i5_program_prepare(string name[, array description][, resource connection]).
Description: Opens a program and prepares it to be run.
Return Values: Resource if open succeeded, false if open failed.
Arguments: •
name - Program name. If a service procedure call is made, the procedure name is given in parentheses, e.g. Lib/Service_Program(PROC)
•
description - PHP-format program description. This should be provided if the program is not described on server. See PHP Data Description for more information.
•
connection - Result of i5_connect
i5_program_prepare_PCML resource i5_program_prepare_PCML (array description[, resource connection]).
Description: Opens a program PCML file and prepares it to be run.
Return Values: Resource if open succeeded, false if open failed.
Arguments:
description - PCML file’s program and parameters information
connection - Result of i5_connect
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 = "
";. } else {. print "Program call failed.
";. }.
Note: Use i5_COMMAND in order to invoke a program without parameters. For example, i5_command("call LIB_NAME/PROGRAM_NAME"). i5_program_close void i5_program_close(resource program).
284
Description: Frees program resource handle.
Return Values: Boolean success value.
Arguments: program - Program resource opened by program_open.
API Reference
Data Retrieval i5_fetch_array 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] ).
Description: Fetches a row of data from the resource.
Return Values: According to the specific fetch function used, it returns either an array or an object containing the data:
•
array - by index and name.
•
assoc - by name.
•
row - by index.
•
object - by name as object properties.
Arguments: •
result - Resource resulting from operation returning data
•
option - Flag specifying which record to fetch.
•
Current record - I5_READ_SEEK
•
Next record - I5_READ_NEXT
•
Previous record - I5_READ_PREV
•
First record - I5_READ_FIRST
•
Last record - I5_READ_LAST
•
Default is I5_READ_NEXT
i5_info array i5_info ( resource result [, int/string field ] ).
Description: Gets information about the file/record.
Return Values: An array with information about record. If there is no way to return whole information; false is returned when the field parameter is omitted.
Arguments:
result - Resource describing file or other record set
field - Integer or string identifying the field. If this parameter is omitted, whole file information is given (when possible).
285
Zend Server 5 for IBM i Reference Manual
i5_field_len int i5_field_len ( resource result, int/string field ).
Description: Gets field length.
Return Values: field's length.
Arguments:
result - Resource describing file or other record set
field - Integer or string identifying the field position or name.
i5_field_name int i5_field_name ( resource result, int field ).
Description: Get field name.
Return Values: field's length.
Arguments:
result - Resource describing file or other record set
field - Integer identifying the field position.
i5_field_scale int i5_field_scale ( resource result, int/string field ).
Description: Gets field scale - number of digits for numeric fields.
Return Values: The number of digits of the field. If the field is not numeric, returns -1.
Arguments:
result - Resource describing file or other record set
field - Integer or string identifying the field position or name.
i5_field_type string i5_field_type ( resource result , int/string field ).
286
Description: Gets field type.
Return Values: Field's type string.
Arguments:
result - Resource describing file or other record set .
field - Integer or string identifying the field position or name.
API Reference
i5_list_fields array i5_list_fields ( resource result ).
Description: Gets list of fields for resource.
Return Values: Array containing field names, in order.
Arguments:
result - Resource describing file or other record set.
i5_num_fields int i5_num_fields ( resource result ).
Description: Get the numbers of fields for resource.
Return Values: Number of fields.
Arguments:
result - Resource describing file or other record set.
i5_result mixed i5_result ( resource result, int/string field]).
Description: Gets one field of the result.
Return Values: Field's contents in current record.
Arguments:
result - Resource describing file or other record set.
field - Integer or string identifying the field position or name.
287
Zend Server 5 for IBM i Reference Manual
Native File Access i5_open resource i5_open (string fileName [, int mode ][,resource connection]).
Description: Opens native i5 file.
Return Values: Resource, if "open" is successful, false otherwise.
Arguments: •
name - File name, may include library
•
mode - File mode to use:
•
o
I5_OPEN_READ - default
o
I5_OPEN_READWRITE
o
I5_OPEN_COMMIT
o
I5_OPEN_SHRRD
o
I5_OPEN_SHRUPD
o
I5_OPEN_SHRNUPD
o
I5_OPEN_EXCLRD
o
I5_OPEN_EXCL
connection - Connection - result of i5_connect
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 bool i5_addnew ( resource file [, int mode] ).
Description: Creates new record in the file. Use setvalue() to set values in new record, then update() to write it to file. i5_new_record() is an atomic function doing all the work.
288
Return Values: Resource if open succeeded, false if "open" failed.
Arguments: •
file - Opened i5 file.
•
mode - I5_ADDNEW_CLEAR: clears all record fields (default).
•
I5_ADDNEW_NOCLEAR: does not clear all record fields
API Reference
i5_edit bool i5_edit ( resource file [, int mode] ).
Description: Sets editing mode for the record. In order for a value to be changed, it should be set in edit mode. This locks the record so that other users cannot edit it simultaneously.
Return Values: Boolean success value. Returns false if the record is already being edited by other used.
Arguments: •
file - i5 file resource.
•
mode - Editing mode: o
I5_EDIT_ONE leaves edit mode after i5_update() and also after reading or i5_delete().
o
I5_EDIT_ALWAYS remains in edit mode until i5_cancel_edit() is called.
o
I5_EDIT_AUTO is called automatically therefore there is no need to call i5_update() after setting values.
i5_delete bool i5_delete ( resource file ).
Description: Remove current record.
Return Values: Boolean success value. Return is false if the record is already being edited by other used.
Arguments: •
file - i5 file resource.
•
i5_cancel_edit
•
bool i5_cancel_edit ( resource result ).
289
Zend Server 5 for IBM i Reference Manual
i5_setvalue bool i5_setvalue (resource file, int/string field, mixed value). bool i5_setvalue (resource file, array values ).
Description: Changes the value of the current record. The record should be in edit mode after i5_edit() or created by i5_addnew().
Return Values: Boolean success value.
Arguments: •
file - i5 file resource.
•
field - Field identifier by name or position.
•
value - Value for the field.
•
values - Set of key=>value parts describing fields to change and their new values.
i5_update bool i5_update ( resource file ).
Description: Commits changes done to the file record after i5_edit() or i5_addnew() into the file.
Return Values: Boolean success value.
Arguments: file - i5 file resource.
i5_range_from bool i5_range_from ( resource file,bool included,array values).
Description: Sets an upper range bound for the file. Once the bound is set, the first line for all seeks becomes the line defined by the range.
Return Values: Boolean success value.
Arguments: •
file - i5 file resource.
•
included - True if the field with this key should be included in the range, false otherwise.
•
290
values - Values for the key fields - array of key=>value pairs.
API Reference
i5_range_to bool i5_range_to (resource result,bool included, array values ).
Description: Sets a lower range bound for the file. Once the bound is set, the last entry for all seeks becomes the entry defined by the range.
Return Values: Boolean success value.
Arguments: •
file - i5 file resource
•
included - True if the field with this key should be included in the range, false otherwise.
•
values - Values for the key fields - array of key=>value pairs.
i5_range_clear bool i5_range_clear (resource file).
Description: Removes range. Reverses the action of range_from() and range_to().
Return Values: Boolean success value.
Arguments: file - i5 file resource
i5_data_seek bool i5_data_seek (resource result, int record_number).
Description: Seeks to a specific record of the result.
Return Values: Boolean success value.
Arguments: •
file - i5 file resource.
•
Record_number - Number of the record to seek to, starting from 0.
291
Zend Server 5 for IBM i Reference Manual
i5_seek bool i5_seek (resource file, int/string operator, array keyValue).
Description: Goes to a specific record in query/file.
Return Values: Boolean success value.
Arguments: •
file - i5 file resource
•
operator - Comparison operator. Position is set to first record satisfying the operator. Available operators:
•
I5_EQ "="
•
I5_GT ">"
•
I5_LT "<"
•
I5_GE ">="
•
I5_LE "<="
•
keyValue - values of the keys to compare
i5_bookmark int i5_bookmark (resource file).
Description: Return Values the ID of the current record.
Return Values: The ID of the current record that can be used with i5_data_seek() to position on this record again.
Arguments: file - i5 file resource.
i5_free_file bool i5_free_file (resource file).
292
Description: Closes file handle and frees file resources.
Return Values: Boolean success value.
Arguments: •
file - i5 file resource.
•
Additional functions to the existing API.
API Reference
i5_new_record bool i5_new_record (resource file, array data).
Description: Creates a new record in the file and inserts data into it.
Return Values: Boolean success value.
Arguments: •
file - Opened i5 file resource.
•
data - Array of data fields conforming to file description.
•
Can be either a flat array or key-value pairs, e.g., i5_setvalue arguments.
i5_update_record bool i5_update_record (resource file, array data).
Description: Updates the current row with given data.
Return Values: Boolean success value.
Arguments:
file - Opened i5 file resource.
data - Array of data fields conforming to file description.
Can be either flat array or key-value pairs, like i5_setvalue arguments.
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'));.
293
Zend Server 5 for IBM i Reference Manual
i5_delete_record bool i5_delete_record(resource file).
Description: Removes current record.
Return Values: Boolean success value. False value is returned if the record is already being edited by other used.
Arguments: File - Opened i5 file resource.
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 array i5_get_keys(resource file).
Description: Gets information about key fields in the file.
Return Values: An array of integers specifying positions for key fields in the file. Can then use i5_info to discover descriptions of these fields.
Arguments: •
294
file - Opened i5 file resource.
API Reference
SQL File Access i5_query resource i5_query ( string query [, resource connection] )
Description: Executes an SQL statement directly
Return Values: For SELECT request returns resource if statement was executed successfully and FALSE in case of error. For INSERT, UPDATE and DELETE requests returns TRUE if statement was executed successfully and FALSE in case of error.
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().
Arguments:
Query - SQL request string such as SELECT, INSERT, DELETE, UPDATES and etc
connection - result of i5_connect
Example: $query = i5_query("SELECT * FROM EACDEMO/SP_CUST"); if(!$query) { echo "Error code: " . i5_errno($query) . " "; echo "Error message: " . i5_errormsg($query) . " "; } else { /* Read records and display */ echo ""; $i = 0; while ($values = i5_fetch_row($query, I5_READ_NEXT) AND ($i < 10)) { $i++; echo "
"; } i5_free_query($query);
295
Zend Server 5 for IBM i Reference Manual
i5_prepare resource i5_prepare ( string query [, resource connection] )
Description: Prepares an SQL statement to be executed Query parameter may include one or several SQL variables if question marks (?) are set at the right places. There are three main advantages using prepared requests in your script: Performance: While preparing a request, database server creates a return optimized path in order to collect the requested data's. Later on, when the i5_prepare prepared request is sent, it will use the path avoiding processor overload with each request sent. Safety: While preparing a request, it is possible to set markers for entry values. Processing the prepared request with entry values, PHP Toolkit checks each entry value to make sure that their type match with the column or the description parameters. Advanced Functionality: Markers not only allow introducing entry values in stored procedure, but also allow collecting OUTPUT and INPUT/OUTPUT recording procedure parameters using i5_bind_param function.
Return Values: Returns a statement resource if the SQL statement was successfully parsed and prepared by the database server. FALSE if the database server returned an error.
Arguments: •
query - SQL request to prepare
•
connection - result of i5_connect
i5_bind_result bool i5_bind_result ( resource result/query, mixed &var1 [,mixed &var2 ...] ) -Orbool i5_bind_result ( resource result/query, mixed &var, string namefield )
Description: Binds a PHP variable to an SQL statement parameter in a statement resource returned by i5_prepare().
296
Returns TRUE on success or FALSE on failure.
Arguments: •
query/stmt - 5_prepare prepared request ID
•
var1 , &var2 - variables to associate referenced list
•
namfield - request field or associated file name
API Reference
i5_execute bool i5_execute ( resource stmt [,params] )
Description: Executes a prepared SQL statement i5_execute executes an SQL request prepared with i5_prepare. If the SQL statement returns a result set, for example, a SELECT statement or a CALL to a stored procedure that returns one or more result sets, you can retrieve a row as an array from the stmt resource using i5_fetch_array, i5_fetch_assoc or i5_fetch_row. If the request creates several results sets, i5_next_result function moves pointer to the next available set. i5_execute is much more efficient than i5_query if the same request has to be run several times with only few parameter changes.. Refer to i5_prepare for a brief discussion of the advantages of using i5_prepare and i5_execute rather than i5_query. A request may contain markers, identified with "?" sign. These markers can be linked to PHP variables (seer i5_bind_param), the results may be linked to PHP variables using i5_bind_result function.
Return Values: Returns Boolean and updated stmt resource in case of success FALSE if it fails
Arguments: •
stmt - A prepared statement returned from i5_prepare
•
params - Input parameters matching any parameter markers contained in the prepared statement.
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);
297
Zend Server 5 for IBM i Reference Manual
i5_getblob string i5_getblob( resource result, int position ) -Orstring i5_getblob( resource result, string namefield )
Description: Reads binary data from a BLOB field type. This function applies to SELECT type (i5_queryi5_query or i5_executei5_execute) requests containing one or more BLOB type fields.
Note: Reading and writing a blob requires a transaction.
Return Values: String with BLOB binary chain or FALSE on failure
Arguments: •
result - File ID
•
position - BLOB field index
•
namfield - BLOB field name
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 bool i5_setblob ( resource stmt, int position, string blob )
Description: Writes a binary data in a BLOB field type. This function only applies to parameterized requests resources and is used the same way as i5_setparam function.
Note: Writing a blob requires a transaction.
Return Values: TRUE on success or FALSE on failure
Arguments: •
298
result - Parameterized file ID
API Reference
•
position - Parameter index
•
blob - Binary chain content
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 bool i5_bind_param ( resource stmt, mixed &var1 [, mixed &var2…]) •
Description: Binds a PHP variable to an SQL statement parameter in a statement resource returned by i5_prepare().
Return Values: TRUE on success or FALSE on failure.
Arguments: •
stmt - i5_prepare prepared request ID
•
&var1 (…) - Variable to link name
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 ) } }
299
Zend Server 5 for IBM i Reference Manual
i5_setparam bool i5_setparam ( resource stmt, int position, mixed value)
Description: Allocates parameter to parameterized request. This function is an alternative to i5_bind_param function (automatically linked). It allows explicit value allocation to a parameter.
Note: Request must be prepared with i5_prepare function.
Return Values: TRUE on success or FALSE on failure
Arguments: •
stmt - i5_prepare prepared request ID
•
position - parameter index (marker) in the request
•
value - parameter allocated value
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."; echo " "; } echo "" .$values[0]. " "; echo "" .$values[1]. " "; echo "" .$values[2]. " "; echo "" .$values[3]. " "; echo "" .$values[4]. " "; echo "" .$values[5]. " "; echo "
"; } i5_setparam($req, 2, "Hercule"); i5_setparam($req, 3, 3.8); $result = i5_execute($req); if ($result) { print "Hercule adding successful.
"; }
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
300
API Reference
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. "; 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()."
"; //echo $err; } else { "
executed"; } echo "
end"; ?>
i5_paramdesc bool i5_paramdesc(resource result, int ASType, int sequence, int length, int decimals, int usage).
Description: Stored procedures parameters descriptions
Return Values: TRUE on success or FALSE on failure
Arguments: •
Result - i5_prepare prepared request ID
•
ASType – Parameter type (e.g. I5_TYPE_PACKED, I5_TYPE_CHAR)
•
Sequence – Parameter sequential number (starting from 0)
•
Length – Parameter length
•
Decimals – Number of decimal position for the numeric parameter type
•
Usage – Parameter input/output (I5_IN, I5_OUT our I5_INOUT)
301
Zend Server 5 for IBM i Reference Manual
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 bool i5_free_query ( resource query )
Description: Frees SQL request result Removes a query type resource (i5_query or i5_execute) from memory This function needs only to be called if your script requires too much memory, when a request returns very large results or if a large requests number are processed and may overload the web server memory. It is recommended to use this function to free memory resource used by SQL request. All memory resources are freed when the SQL request is ended.
302
Return Values: TRUE on success or FALSE on failure
Arguments: query - query resource
API Reference
Transactions i5_transaction bool i5_transaction ( int mode [, resource connection] )
Description: Starts transaction.
Return Values: Returns TRUE if transaction has started, FALSE in case of error
Arguments: •
mode - Transaction modes: o
I5_ISOLEVEL_CHG - READ UNCOMMITED, READ WRITE (UR) - Modified records remain locked. - Modifications are showed
o
I5_ISOLEVEL_CS - READ COMMITED (CS) - Read records are locked. - Modified records remain locked. - Changes are not showed
o
I5_ISOLEVEL_ALL - REPEATABLE READ (RS) - Read records remain locked. - Modified records remain locked. - Modifications are not showed.
o
I5_ISOLEVEL_NONE - No transactions - Each record is commited immediately
•
connection - result of i5_connect
Example:
305
Zend Server 5 for IBM i Reference Manual
Data Queues i5_dtaq_prepare resource i5_dtaq_prepare(string name, array description [,int key][,resource connection])
Description: Opens a data queue with optional description.
Return Values: Resource if OK, false if failed.
Arguments: •
name - The queue name
•
description - Data description in format defined by program¬_prepare. For more, see PHP Toolkit Data Description.
•
key - key size - for keyed DataQ
•
connection - Connection - result of i5_connect
i5_dtaq_receive mixed i5_dtaq_receive(resource queue[, string/int operator, string key][, int timeout])
Description: Reads data from the data queue.
Return Values: False if could not read because of error or timeout, the data read from the queue otherwise.
306
Arguments: •
queue - resource received from dtaq_open
•
operator:
•
"EQ"
•
"GT"
•
"LT"
•
"GE"
•
"LE"
•
key- key value to look for
•
timeout - timeout value in seconds
API Reference
i5_dtaq_send bool i5_dtaq_send(resource queue, string key, mixed data)
Description: Puts data to the data queue.
Return Values: False if could not be written because of error, true otherwise.
Arguments: •
queue - resource received from dtaq_open
•
key - key value to look for
•
data - data to put into the queue
The data should conform to the description format, and can be either in flat array or key->value pair array. i5_dtaq_close bool i5_dtaq_close(resource queue) •
Description: Free program resource handle.
•
Return Values: Bool success value.
•
Arguments: queue - resource received from dtaq_open
Example 1: "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: "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); ?>
307
Zend Server 5 for IBM i Reference Manual
System Values i5_get_system_value string i5_get_system_value(string name[, resource connection]).
Description: Retrieves system value
Return Values: System value, false if not found.
Arguments: •
name - Name of the system value.
•
connection - Connection - result of i5_connect.
Example: print "Date is: ".i5_get_system_value("QDATE");.
308
API Reference
User Spaces i5_userspace_create bool i5_userspace_create(properties[, resource connection]).
Description: Creates a new user space object.
Return Values: Boolean success value
Arguments: •
properties o
I5_INITSIZE - The initial size of the user space being created. This value must be from 1 byte to 16, 776, 704 bytes.
o
I5_DESCRIPTION - user space description
o
I5_INIT_VALUE - The initial value of all bytes in the user space.
o
I5_EXTEND_ATTRIBUT - extended attribute. The extended attribute must be a valid *NAME. For example, an object type of *FILE has an extended attribute of PF (physical file), LF (logical file), DSPF (display file), SAVF (save file), and so on.
o
I5_AUTHORITY - The authority you give users who do not have specific private or group authority to the user space
•
o
I5_LIBNAME - Library name where the user space is located
o
I5_NAME - User space name (10 char max)
connection - Result of i5_connect
i5_userspace_prepare resource i5_userspace_prepare(string name, array description [, resource connection]).
Description: Opens a user space and prepares it to be run.
Return Values: Resource if open succeeded, false if open failed.
Arguments: •
name - User space name in library/object format
•
description - Data description in format defined by program_prepare. See PHP Data Description.
•
connection - Result of i5_connect
309
Zend Server 5 for IBM i Reference Manual
i5_userspace_get resource i5_userspace_get(resource user space, array params)
Description: Retrieve user space data.
Return Values: Boolean success value.
Arguments: •
user space - User Space resource opened by i5_userspace_prepare
•
params - Parameters according to description. If given as flat array, then parameters are assigned in order
i5_userspace_put bool i5_userspace_put(resource user space, params)
Description: Add user space data
Return Values: Boolean success value.
Arguments: •
user - space User Space resource opened by i5_userspace_prepare
•
params - Parameters according to description. If given as flat array, then parameters are assigned in order
310
API Reference
Job Log List i5_jobLog_list resource i5_jobLog_list( [array elements, resource connection] )
Description: Opens job log.
Return Values: The resource for fetching job log list if OK and false if failed.
Arguments: •
elements - JobName, JobUser, JobNumber, MaxMessage, Direction (default is current job)
•
connection - Result of i5_connect
Use i5_jobLog_list_read function to retrieve the job entries from this handle. i5_jobLog_list_read array i5_jobLog_list_read(resource list)
Description: Get an array for a job log entry.
Return Values: Array with the message element if OK, false if failed.
Arguments: list - Resource returned by i5_jobLog_list function
i5_jobLog_list_close bool i5_jobLog_list_close (resource handle)
Description: Close handle received from i5_jobLog_list().
Return Values: Boolean success value
Arguments: handle - Job list handle as returned by i5_jobLog_list()
311
Zend Server 5 for IBM i Reference Manual
Active Job List i5_job_list resource i5_job_list( [array elements, resource connection] )
Description: Open active job list.
Return Values: The resource for fetching job list if OK and false if failed.
Arguments: •
elements - JobName, JobUser, JobNumber, JobType, Direction (default is current job)
•
connection - Result of i5_connect
Use i5_job_list_read function to retrieve the job entries from this handle. i5_job_list_read array i5_job_list_read(resource list)
Description: Get an array for an active job entry.
Return Values: Array with the job entry element if OK, false if failed.
Arguments: List - Resource returned by i5_job_list function
i5_job_list_close bool i5_job_list_close (resource handle) Description: Close handle received from i5_job_list(). Return Values: Boolean success value Arguments: •
312
handle - Job list handle as returned by 15_job_list()
API Reference
Data Areas i5_data_area_create bool i5_data_area_create(string name, int size[, resource connection]).
Description: Creates data area of given size
Return Values: Boolean success value.
Arguments: •
name - Name of the data area.
•
size - Size in bytes of the data area.
•
connection - result of i5_connect .
i5_data_area_read string data_area_read(string name[, int offset, int length][, resource connection]).
Description: Reads data from the area
Return Values: String data if read successful, false if read failed (including when offset is wrong).
Arguments: •
name - Name of the data area.
•
offset - Offset for the data.
•
length - Length of the data to read, -1 means whole area.
•
connection - Connection - result of i5_connect.
If no offset is specified, all the area is read.
313
Zend Server 5 for IBM i Reference Manual
i5_data_area_write bool data_area_write(string name, string value[, int offset, int length][, resource connection]).
Description: Writes data to the area
Return Values: Boolean success value.
Arguments: •
name - Name of the data area.
•
value - Value to write.
•
Offset - Offset for the data.
•
length - Length of the data to read.
•
connection - result of i5_connect
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 bool data_area_delete(string name[, resource connection]).
314
Description: Delete the data area
Return Values: Boolean success value.
Arguments: •
name - Name of the data area.
•
connection - Connection - result of i5_connect.
API Reference
Spooled File i5_spool_list resource i5_spool_list([array description][, resource connection])
Description: Create an spool file lists, of certain output queue or for all queues.
Return Values: resource if OK, false if failed
Arguments: •
description - The data by which the sppol files will be filtered, array with following keys:
•
username - username that created the job
•
outq - qualified name for the output queue containing the spool file
•
userdata - the user-supplied key data for the spool file. All keys are optional and can be provided together
•
connection - result of i5_connect.
i5_spool_list_read array i5_spool_list_read(resource spool_list)
Description: Gets spool file data from the queue.
Return Values: next spool file data array in the list, or false if queue is empty.
The data will be formated using SPLF0300 format. See following link for more details: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/QUSLSPL.htm
Arguments: Spool_list resource received from i5_spool_list
i5_spool_list_close void i5_spool_list_close(resource spool_list)
Description: Free spool list resource
Return Values: Boolean success value
Arguments: Queue - resource received from i5_spool_list
315
Zend Server 5 for IBM i Reference Manual
i5_spool_get_data string i5_spool_get_data(string spool_name, string jobname, string username, integer job_number, integer spool_id [,string filename])
Description: Get the data from the spool file.
Return Values: String if no file name passed as parameter, false if function failes
Arguments: •
spool_name - The spool file name
•
job_name - The name of the job that created the file
•
job_number - The number of the job that created the file
•
username - The username of the job that created the file
•
spool_id - ID of the spool file in the queue (as returned by outq_read)
•
filename - IFS filename to store the data. If not provided, the data is returned as string
316
API Reference
Object Listing i5_objects_list resource i5_objects_list(string library, [string name, string type, resource connection])
Description: Open an object list.
Return Values: Resource for fetch if everything is OK, false on error.
Arguments: •
library - Library name (can be also *CURLIB or I5_CURLIB)
•
name - Name or wildcard of objects to read, default is ”r;all”.
•
type - Object type to fetch (*ALL or I5_ALL_OBJECTS for all)
•
connection - Connection - result of i5_connect
i5_objects_list_read array i5_objects_list_read (resource list)
Description: Get an array for an object list entries.
Return Values: Array with the object element if OK; false if failed.
Arguments: List - Resource returned by i5_objects_list
i5_ objects_list _close bool i5_ objects_list_close (resource handle)
Description: Close handle received from i5_ objects_list ().
Return Values: Boolean success value
Arguments: handle - Object list handle as returned by i5_ objects_list ()
317
Zend Server 5 for IBM i Reference Manual
PHP Toolkit Data Description Short Data Format Data structures are defined via PHP as follows: Main data is an array of key-value pairs, where key is the parameter name and value is the array of:
type - one of Data types
type modifier •
for CHAR, BYTE - integer describing length. Length can be number or name of the variable holding the length in the data structure.
•
for PACKED, ZONED - string "NUMBER.NUMBER" defining length and precision
•
for STRUCT - array containing data definition of the structure
•
for INT, FLOAT - ignored
direction (optional) - one of I/O values
count (optional)
if integer - repetition count if the field is an array
if string - reference to the repetition count field
Example: array(I5_TYPE_CHAR, 50), "age" => array(I5_TYPE_INT, 0), "ID" => array(I5_TYPE_BYTE, 10) ); $data = array( "person" => array(I5_TYPE_STRUCT, $person), "last_accesses" => array(I5_TYPE_INT, 0, I5_OUT, 3), "account_balance" => array(I5_TYPE_PACKED, "10.3", I5_OUT) ); $prg = i5_program_prepare("MYLIB/PERSONPGM", $data); ?>
In any place data description is required; the name of the file with external data structure description can be used instead.
318
API Reference
Long Data Format Data structure is defined via PHP as follows: Main data is the array of values, having following fields:
Name - name of the field
Type - type of the field, can be one of Data types
Length •
for CHAR, BYTE - integer describing length. Length can be number or name of the variable holding the length in the data structure.
•
for PACKED, ZONED - string "NUMBER.NUMBER" defining length and precision
•
for STRUCT - array containing data definition of the structure
•
for INT, FLOAT - ignored
IO - can be one of I/O values
Data structure is defined via PHP as follows: •
DSName - name of the parameter
•
DSParm (optional) - array of the parameter of the Data structure. Each parameter is defined by a data definition in the same format as described here.
•
Count (optional) - repetition count if the field is an array
•
CountRef (optional) - reference to the repetition count if the field is an array
Example: "P1", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10", "count"=>5), array("Name"=>"P2C", "IO"=>I5_INOUT, "Type"=>I5_TYPE_LONG), array("Name"=>"P2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>"1", "countRef"=>"P2C"), array("DSName"=>"PS", "count"=>2, "DSParm"=>array( array("Name"=>"PS1", "IO"=>I5_IN|I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10"), array("Name"=>"PS2", "IO"=>I5_IN|I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10"), array("Name"=>"PS3", "IO"=>I5_IN|I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10"), ) ) ); $prg = eac_program_prepare("MYLIB/PERSONPGM", $description); ?>
319
Zend Server 5 for IBM i Reference Manual
Data Types I5_TYPE_CHAR
I5_TYPE_INT
I5_TYPE_PACKED
I5_TYPE_ZONED
I5_TYPE_FLOAT
I5_TYPE_BYTE
I5_TYPE_STRUCT (long format uses DSName to define structure)
I/O Values
I5_IN
I5_OUT
These values can be OR'ed together to get input-output value:
I5_TYPE_RETVAL - return value for procedure call
I5_TYPE_BYVAL - by-value parameter for procedure call
default is input
Error Types I5_ERR_OK
I5_ERR_PHP_COMMAND_E
I5_ERR_PHP_HDLBAD
I5_ERR_TOOMUCHOPEN
RROR
I5_ERR_PHP_OPTIONSNUM
FILE
I5_ERR_PHP_GET_SYSVAL
BER
I5_ERR_INVALIDPTR
I5_ERR_PHP_BAD_DEF
I5_ERR_PHP_TYPEPARAM
I5_ERR_INVALIDFIELDNB
I5_ERR_PHP_NO_DS_VALU
I5_ERR_PHP_TYPEGET
R
E
I5_ERR_PHP_BOOKMARK
I5_ERR_INVALIDKEYNBR
I5_ERR_ENDOFOCC
I5_ERR_PHP_CALL_BINDPA
I5_ERR_INVALIDOPENMO
I5_ERR_DESC_UNEXP
RAM
DE
I5_ERR_DESC_WRONG_DA
I5_ERR_PHP_BINDPARAM
I5_ERR_RECORDLOCKED
TAOP
I5_ERR_PHP_BLOBSIZE
I5_ERR_FILELIMITS
I5_ERR_PHP_BAD_PROG_
I5_ERR_PHP_INTERNAL
I5_ERR_INVALIDSEQ
NAME
I5_ERR_PHP_NO_COMMAND
I5_ERR_NOLINKDEFINED
I5_ERR_PHP_NOT_DTAQ_K
I5_ERR_PHP_NO_KEYNAME
I5_ERR_NULLNOTALLOW
EY
I5_ERR_PHP_NO_ZVALUE
ED
I5_ERR_PHP_DESC_EMPTY
I5_ERR_PHP_DATAREA_REA
I5_ERR_WRONGLOGIN
I5_ERR_PHP_LIST_PROP
D
I5_ERR_FIELDNULL
I5_ERR_PHP_API_LENGTH
I5_ERR_PHP_ELEMENT_MIS
I5_ERR_INVALIDINFO
I5_ERR_ERROR
SING
320
API Reference
I5_ERR_RECORDCHANG
I5_ERR_MEMALLOC
I5_ERR_PHP_BAD_KEYNAM
ED
I5_ERR_FIELDNOTFOUND
E
I5_ERR_NOTINTRAN
I5_ERR_INVALIDKEYLEN
I5_ERR_PARAMNOTFOUND
I5_ERR_PHP_HDLCONN
I5_ERR_NOTENABLETOUP
I5_ERR_PHP_BAD_DS_INPU
I5_ERR_PHP_OPTIONSTY
DATE
T
PE
I5_ERR_RECORDNOTFOUN
I5_ERR_DQDESC_UNSUPP
I5_ERR_PHP_RESOURCE
D
I5_ERR_INCORRECTVALUE
_BAD
I5_ERR_BEOF
I5_ERR_PHP_AS400_MESSA
I5_ERR_PHP_NBPARAM_
I5_ERR_NOTCONNECTED
GE
BAD
I5_ERR_NORANGESET
I5_ERR_PHP_DTAQ_BADKE
I5_ERR_PHP_OPERATOR
I5_ERR_NOCURRENTRECO
Y
_BAD
RD
I5_ERR_PHP_BAD_LEN_PRO
I5_ERR_PHP_NOT_BOOK
I5_ERR_BADSESSION
P
MARK
I5_ERR_NOTENOUGHRIGH
I5_ERR_PHP_SPOOL_FILE_F
I5_ERR_PHP_GETPARAM
TS
OPEN
I5_ERR_PHP_PARAM_DE
I5_ERR_INVALIDTYPE
SC
I5_ERR_NOTTYPEPROPER
I5_ERR_PHP_VARIABLE
TY
I5_ERR_PHP_EXECUTE
I5_ERR_ALLREADYINTRAN
I5_ERR_PHP_EMPTY_AR
I5_ERR_PHP_HDLDFT
RAY I5_ERR_PHP_NO_PARMN AME
Data structures are defined via PHP as follows: Main data is the array of values, having the following fields:
Name - name of the field
Type - type of the field, can be: •
I5_TYPE_SHORT
•
I5_TYPE_LONG
•
I5_TYPE_DOUBLE
•
I5_TYPE_BIN
•
I5_TYPE_DATE
•
I5_TYPE_TIME
•
I5_TYPE_TIMESTP
•
I5_TYPE_DBCS
321
Zend Server 5 for IBM i Reference Manual
•
I5_TYPE_LONG8
•
I5_TYPE_NUMERICCHAR
•
I5_TYPE_BLOB
•
I5_TYPE_CLOB
•
I5_TYPE_UNICODE
•
I5_TYPE_VARCHAR
•
I5_TYPE_VARBIN
Length •
For CHAR, BYTE - integer describing length. Length can be number or name of the variable holding the length in the data structure.
•
For PACKED, ZONED - string "NUMBER.NUMBER" defining length and precision
•
For STRUCT - array containing data definition of the structure
•
For INT, FLOAT - ignored
•
I5_IN
•
I5_OUT
•
default is input, these values can be OR'ed together to get input-output value
IO
Count (optional) - repetition count if the field is an array
CountRef (optional) - reference to the repetition count if the field is an array
Data structure is defined via PHP as follows:
DSName - name of the parameter
DSParm (optional) - array of the parameter of the Data structure. Each parameter is defined by a simple data definition.
Example: "P1", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10", "count"=>5), array("Name"=>"P2C", "IO"=>I5_INOUT, "Type"=>I5_TYPE_LONG), array("Name"=>"P2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>"1", "countRef"=>"P2C"), array("DSName"=>"PS", "count"=>2, "DSParm"=>array( array("Name"=>"PS1", "IO"=>I5_IN|I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10"), array("Name"=>"PS2", "IO"=>I5_IN|I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10"), array("Name"=>"PS3", "IO"=>I5_IN|I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"10"), ) ) ); $prg = i5_program_prepare("MYLIB/PERSONPGM", $description); ?>
322
API Reference
Command Constants I5_CURLIB (Default Value = "*CURLIB") I5_ALL_OBJECTS (Default value = "*ALL") I5_ALL_NAMES (Default value = "*") I5_LIST_MINIMAL I5_LIST_DETAILED I5_LIST_FULL
Active Job (i5_job_list) array elements constants i5_JOB_ACT_JOB_STS
I5_JOB_ALW_MULTI_THRE
I5_JOB_ACT_ENDJOB_ST
I5_JOB_BRKMSG
ADS
S
I5_JOB_CNTRYID
I5_JOB_CANCEL_KEY
I5_JOB_CCSID
I5_JOB_POOL_ID
I5_JOB_USRPRF
I5_JOB_COMPLETION_ST
I5_JOB_PROCESS_UNIT_TIM
I5_JOB_CHAR_ID_CTRL
S
E_DB
I5_JOB_DATETIME_ACTIVE
I5_JOB_PROCESS_UNIT_
I5_JOB_DATETIME_SCHED
I5_JOB_DATETIME_JOBQ
TIME
I5_JOB_DATSEP
I5_JOB_DBCS_CAP
I5_JOB_DATETIME_IN
I5_JOB_DFTWAIT
I5_JOB_DEVRCYACN
I5_JOB_DATFMT
I5_JOB_DFTCCSID
I5_JOB_DECFMT
I5_JOB_DDM_HANDLE
I5_JOB_ENDSEV
I5_JOB_ENDSTS
I5_JOB_DEVNAME
I5_JOB_FUNC_NAME
I5_JOB_FUNC_TYPE
I5_JOB_DATETIME_END
I5_JOB_GRPPRFNAME
I5_JOB_GRPPRFNAME_SU
I5_JOB_EXITKEY
I5_JOB_ACCOUNT_CODE
P
I5_JOB_SIGNED_JOB
I5_JOB_QUEUE_NAME
I5_JOB_DATE
I5_JOB_INQMSGRPLY
I5_JOB_JOBMSGQFL
I5_JOB_QUEUE_PTY
I5_JOB_DESC_NAME
I5_JOB_USRID_SETTING
I5_JOB_JOBMSGQ_SIZE
I5_JOB_SWITCHES
I5_JOB_TYPE_ENHANCED
I5_JOB_END_REASON
I5_JOB_USRID
I5_JOB_LOGCLPGM
I5_JOB_LANGID
I5_JOB_LOG_PENDING
I5_JOB_MODE_NAME
I5_JOB_LOGSEV
I5_JOB_LOGLVL
I5_JOB_MAX_THREADS
I5_JOB_MAX_PROC_UNIT_
I5_JOB_LOGTEXT
I5_JOB_MSGRPL
TIME
I5_JOB_MAX_TMP_STG_K
I5_JOB_ MCH_LCKW
I5_JOB_MAX_TMP_STG_M
I5_JOB_MEM_POOL_NAM
I5_JOB_OUTQ_NAME
I5_JOB_INTERACTIVE_TRS
E
I5_JOB_PRTDEVNAME
I5_JOB_NONDB_LCKW
I5_JOB_DB_LCKWAIT
I5_JOB_PROG_RETCODE
I5_JOB_OUTQ_PTY
I5_JOB_AUX_IOREQ
I5_JOB_RESPONSE_TIME
I5_JOB_PURGE
I5_JOB_PRTTEXT
323
Zend Server 5 for IBM i Reference Manual
I5_JOB_STRSEQ
I5_JOB_PENDING_SGNSET
I5_JOB_PRD_RETCODE
I5_JOB_SBMJOB
I5_JOB_RUNPTY
I5_JOB_PROCESS_ID
I5_JOB_SYSPOOLID
I5_JOB_STS_MSGHDL
I5_JOB_ROUTING_DATA
I5_JOB_SGNSTS
I5_JOB_SBMMSGQ
I5_JOB_STS_JOBQ
I5_JOB_TIMSEP
I5_JOB_SPCLENV
I5_JOB_SBSD
I5_JOB_TMPSTGK
I5_JOB_SVRTYPE
I5_JOB_SGNBLK_MASK
I5_JOB_TIME_NONDB_LCKW
I5_JOB_TIMESLICE
I5_JOB_SPLFILE_ACTION
I5_JOB_TIME_DB_LCKW
I5_JOB_TIMESLICE_END
I5_JOB_THREADCNT
I5_JOB_TIME_MCH_LCKW
Job Log Constants (i5_jobLog_list) array elements constants I5_LOBJ_MESSAGE_SEVERITY
I5_LOBJ_MESSAGE_TY
I5_LOBJ_MESSAGE_FILENA
I5_LOBJ_MESSAGE_IDENTIFIE
PE
ME
R
I5_LOBJ_DATASENT
I5_LOBJ_TIMESENT
I5_LOBJ_ALERTOPT
I5_LOBJ_RPLDATA1
I5_LOBJ_MSG
I5_LOBJ_MSGDTA
I5_LOBJ_MSGHLP
I5_LOBJ_MSGHLPDTA
I5_LOBJ_MSGHLPDTAFMT
I5_LOBJ_DFTRPLY
I5_LOBJ_SNDNAME
I5_LOBJ_SNDTYPE
I5_LOBJ_SNDPGM
I5_LOBJ_SNDMOD
I5_LOBJ_SNDPROC
I5_LOBJ_RCVTYPE
I5_LOBJ_RCVPROG
I5_LOBJ_RCVMOD
I5_LOBJ_RCVPROC
I5_LOBJ_MSGFILE
I5_LOBJ_PROBLEMID
I5_LOBJ_RPLYSTS
I5_LOBJ_RQSSTS
I5_LOBJ_RQSLVL
I5_LOBJ_TXTCCSID
I5_LOBJ_DATACCSID
I5_LOBJ_MESSAGE_FILELIBRA RY I5_LOBJ_TIMESENT_MICRO
Errors I5_TYPE_CHAR I5_ERR_OK I5_ERR_ERROR I5_ERR_TOOMUCHOPENFILE I5_ERR_MEMALLOC
324
API Reference
Data Retrieval Errors I5_ERR_INVALIDPTR
I5_ERR_NOLINKDEFINED
I5_ERR_FIELDNOTFOUND
I5_ERR_NOCURRENTRECORD
I5_ERR_INVALIDFIELDNBR
I5_ERR_NULLNOTALLOWED
I5_ERR_INVALIDKEYLEN
I5_ERR_BADSESSION
I5_ERR_INVALIDKEYNBR
I5_ERR_WRONGLOGIN
I5_ERR_NOTENABLETOUPDATE
I5_ERR_NOTENOUGHRIGHTS
I5_ERR_INVALIDOPENMODE
I5_ERR_FIELDNULL
I5_ERR_RECORDNOTFOUND
I5_ERR_INVALIDTYPE
I5_ERR_RECORDLOCKED
I5_ERR_INVALIDINFO
I5_ERR_BEOF
I5_ERR_NOTTYPEPROPERTY
I5_ERR_FILELIMITS
I5_ERR_RECORDCHANGED
I5_ERR_NOTCONNECTED
I5_ERR_ALLREADYINTRAN
I5_ERR_INVALIDSEQ
I5_ERR_NOTINTRAN
I5_ERR_NORANGESET
Function Errors I5_ERR_PHP_HDLDFT
I5_ERR_PHP_NO_ZVALUE
I5_ERR_PHP_HDLCONN
I5_ERR_PHP_COMMAND_ERROR
I5_ERR_PHP_HDLBAD
I5_ERR_PHP_DATAREA_READ
I5_ERR_PHP_OPTIONSTYPE
I5_ERR_PHP_GET_SYSVAL
I5_ERR_PHP_OPTIONSNUMBER
I5_ERR_PHP_ELEMENT_MISSING
I5_ERR_PHP_RESOURCE_BAD
I5_ERR_PHP_BAD_DEF
I5_ERR_PHP_TYPEPARAM
I5_ERR_PHP_BAD_KEYNAME
I5_ERR_PHP_NBPARAM_BAD
I5_ERR_PHP_NO_DS_VALUE
I5_ERR_PHP_TYPEGET
I5_ERR_PARAMNOTFOUND
I5_ERR_PHP_OPERATOR_BAD
I5_ERR_ENDOFOCC
I5_ERR_PHP_BOOKMARK
I5_ERR_PHP_BAD_DS_INPUT
I5_ERR_PHP_NOT_BOOKMARK
I5_ERR_DESC_UNEXP
I5_ERR_PHP_CALL_BINDPARAM
I5_ERR_DQDESC_UNSUPP
I5_ERR_PHP_GETPARAM
I5_ERR_DESC_WRONG_DATAOP
I5_ERR_PHP_BINDPARAM
I5_ERR_INCORRECTVALUE
I5_ERR_PHP_PARAM_DESC
I5_ERR_PHP_BAD_PROG_NAME
I5_ERR_PHP_BLOBSIZE
I5_ERR_PHP_AS400_MESSAGE
I5_ERR_PHP_VARIABLE
I5_ERR_PHP_NOT_DTAQ_KEY
325
Zend Server 5 for IBM i Reference Manual
I5_ERR_PHP_INTERNAL
I5_ERR_PHP_DTAQ_BADKEY
I5_ERR_PHP_EXECUTE
I5_ERR_PHP_DESC_EMPTY
I5_ERR_PHP_NO_COMMAND
I5_ERR_PHP_BAD_LEN_PROP
I5_ERR_PHP_EMPTY_ARRAY
I5_ERR_PHP_LIST_PROP
I5_ERR_PHP_NO_KEYNAME
I5_ERR_PHP_SPOOL_FILE_FOPEN
I5_ERR_PHP_NO_PARMNAME
I5_ERR_PHP_API_LENGTH
326
API Reference
Program Samples i5 Program Call The i5 program call process contains the following PHP functions:
i5_connect
i5_program_prepare
i5_program_call
i5_close
The sample PHP script below invokes an i5 program: \n"); $errorTab = i5_error(); var_dump($errorTab); die(); } /* Prepare File for execution */ $desc = array ( array ("name"=>"code", "io"=>I5_INOUT, "type" => I5_TYPE_CHAR, "length"=> "10"), array ("name"=>"name", "io"=>I5_INOUT, "type" => I5_TYPE_CHAR, "length"=> "10"), ); $prog = i5_program_prepare("EACDEMO/TESTSTP2", $desc); if ($prog === FALSE) { $errorTab = i5_error(); echo "Program prepare failed
\n"; var_dump($errorTab); die(); } /* Execute Program */ $params = array ("code"=>" ","name"=>" "); $retvals = array("code"=>"code","name"=>"name"); $ret = i5_program_call($prog, $params, $retvals) ; echo "The return values are:
", "Name: ", $name, "
Code: ", $code, "
"; if ($ret === FALSE) { $errorTab = i5_error(); echo "FAIL : i5_program_call failure code
"; var_dump($errorTab); die(); } $close_val = i5_program_close ($prog); if ($close_val === false ) { print ("FAIL : i5_program_close returned fales, closing an open prog.
\n"); $errorTab = i5_error(); var_dump($errorTab); } i5_close($conn) || print ("FAIL : Failed to disconnect from server :$i5_server_ip"); ?>
327
Zend Server 5 for IBM i Reference Manual
Service Program "PHPAIX")); if (is_bool($Hdlcon) && $Hdlcon == FALSE) die(i5_errormsg()); echo "Connected!
"; $desc = array ( array ("name"=>"code", "io"=>I5_INOUT, "type" => I5_TYPE_CHAR, "length"=> "10"), array ("name"=>"name", "io"=>I5_INOUT, "type" => I5_TYPE_CHAR, "length"=> "10"), ); $ret = $prog = i5_program_prepare("EACDEMO/TESTP2SRV(TESTSTMOD)", $desc); if (!$ret){ getError(I5_ERR_OK, -1); } else { echo "1. Prepare - It works!
"; } $hdlPgm = $ret; $parameter = array("code"=>" ", "name"=>" "); $parmOut = array("code"=>"code", "name"=>"name"); $ret = i5_program_call($hdlPgm, $parameter, $parmOut); if (!$ret){ getError(I5_ERR_OK, -1); } else { echo "2. Call - It works!
"; } echo "code : $code
name : $name
"; ?>
Data Retrieval \n"; } $fealds = i5_list_fields($HdlFile); $fetch_array = i5_fetch_array($HdlFile,I5_READ_FIRST); $fetch_assoc = i5_fetch_assoc($HdlFile,I5_READ_NEXT); $fetch_object = i5_fetch_object($HdlFile,I5_READ_PREV); $fetch_row = i5_fetch_row($HdlFile,I5_READ_LAST); print_r($fetch_array); echo"
\n
\n"; print_r($fetch_assoc); echo"
\n
\n"; print_r($fetch_object); echo"
\n
\n"; print_r($fetch_row); echo"
\n
\n"; $info = i5_info($HdlFile,1); print_r($info); echo"
\n
\n"; $field_length = i5_field_len($HdlFile,1); $field_name = i5_field_name($HdlFile,1); $field_type = i5_field_type($HdlFile,1); $field_scale = i5_field_scale($HdlFile,1); echo "Field Name: {$field_name}
\n Field Lenght: {$field_length}
\n Field Type: {$field_type}
\n Field Scale: {$field_scale}
\n"; $list_fields = i5_list_fields($HdlFile); print_r($list_fields); $num_fields = i5_num_fields($HdlFile); echo "
\n {$num_fields}"; $result = i5_result($HdlFile,2);
328
API Reference
echo "
\n {$result}"; i5_close($Hdlcon); ?>
Native File Access sample "; $fetch = i5_fetch_row($file, I5_READ_NEXT); echo $fetch[0], " ",$fetch[1], " ", $fetch[2], "
"; i5_range_clear($file); $fetch = i5_fetch_row($file, I5_READ_FIRST); echo $fetch[0], " ",$fetch[1], " ", $fetch[2], "
"; i5_data_seek($file, 2); $rowTab = i5_fetch_row($file); echo $rowTab[0], " ",$rowTab[1], " ", $rowTab[2], "
"; $tab=array(1510); $seek = i5_seek($file, "=", $tab); $rowTab = i5_fetch_row($file); echo $rowTab[0], " ",$rowTab[1], " ", $rowTab[2], "
"; $id = i5_bookmark($file); echo $id, "
"; i5_new_record($file, array('1229', 'Kauai Dive Shoppe ', 'Irica', 'Norman', '4-976 Sugarloaf Hwy', 'Suite 103', 'Kapaa Kauai', 'HI', '94766-1234', 'US', '808-555-0269', '808-555-0278')); i5_fetch_row($file,I5_READ_FIRST); i5_update_record($file,array("FIRSTNAME"=>"Lina","LASTNAME"=>"Karasko")); i5_delete_record($file); $keys = i5_get_keys($file); echo $keys; i5_free_file($file); ?>
329
Zend Server 5 for IBM i Reference Manual
Data Queues Data Queue Without Key "DATA", "Type"=>I5_TYPE_CHAR, "Length"=>"50"); $queue = i5_dtaq_prepare("eacdemo/DTAQ_FIFO", $description); $ret = i5_dtaq_send($queue,"","the dataqueue test data"); var_dump($ret); echo "
\n"; if(!$ret) var_dump(i5_error()); $ret = i5_dtaq_receive($queue); var_dump($ret); i5_dtaq_close($queue); i5_close($conn); ?>
Data Queue With key "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); var_dump($dtaqHdl_KEY); echo "
\n"; $parameter = array("PS1"=>"test1", "PS2"=>13.1415, "PS3"=>"test2"); $key = "abcd"; $ret = i5_dtaq_send($dtaqHdl_KEY, $key, $parameter); var_dump($ret); echo "
\n"; $ret = i5_dtaq_receive($dtaqHdl_KEY, "EQ", $key); var_dump($ret); i5_dtaq_close($dtaqHdl_KEY); i5_close($conn); ?>
System Values
User Spaces 10,
330
API Reference
I5_DESCRIPTION=>"Created by PHP", I5_INIT_VALUE=>"A", I5_EXTEND_ATTRIBUT=>"File", I5_AUTHORITY=>"*ALL", I5_LIBNAME=>"EACDEMO", I5_NAME=>"USERSPACE" ); $ret = i5_userspace_create($property); if ($ret) echo "1. It works!
\n"; $description = Array( array("Name"=>"filler0", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>"64"), array("Name"=>"generic", "IO"=>I5_INOUT, "Type"=>I5_TYPE_LONG), array("Name"=>"filler", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>"36"), array("Name"=>"outputsize", "IO"=>I5_INOUT, "Type"=>I5_TYPE_LONG), array("Name"=>"offsetInput", "IO"=>I5_INOUT, "Type"=>I5_TYPE_LONG) ); $parameter = Array( "filler0"=>"AAAA", "generic"=>10, "filler"=>"BBB", "outputsize"=>100, "offsetInput"=> 0 ); $parmOut = array("filler0"=>"filler0", "filler"=>"filler", "generic"=>"generic", "outputsize"=>"outputsize", "offsetInput"=>"offsetInput"); $UspcHdlBad = i5_userspace_prepare("EACDEMO/USERSPACE", $description); if ($UspcHdlBad) echo "2. It works!
\n"; $ret = i5_userspace_put($UspcHdlBad, $parameter); if ($ret) echo "3. It works!
\n"; $ret = i5_userspace_get($UspcHdl, $parmOut); if (!$ret) echo "4. It works!
\n"; if ($ret) echo "5. It works!"; var_dump($ret);*/ $ret = i5_command("DLTUSRSPC USRSPC(EACDEMO/USERSPACE)"); if ($ret) echo "6. It works!"; i5_close($conn); ?>
Active Job List "PHPAIX")); if (is_bool($Hdlcon) && $Hdlcon == FALSE){ die(i5_errormsg());} echo "i5_job_list: "; $ret = i5_job_list(); if (!$ret) die(i5_errormsg()); else echo "It works!
"; $listHdl = $ret; echo 'i5_job_list_read: '; $ret = i5_job_list_read($listHdl); if (!$ret) die(i5_errormsg()); else echo "It works!
"; echo 'i5_job_list_close: '; $ret = i5_job_list_close($listHdl); if (!$ret) { die(i5_errormsg()); } else { echo "It works!
";
331
Zend Server 5 for IBM i Reference Manual
} $listHdl = i5_job_list(array(I5_JOBNAME=>"*ALL", I5_JOBTYPE=>"S")); if (is_bool($listHdl)) die(i5_errormsg()); else echo "List
";
$a= 0; $ret = true; while($ret && $a < 3){ echo "
"; $ret = i5_job_list_read($listHdl); $a ++; if (is_bool($ret)) die(i5_errormsg()); else { print_r($ret);echo "
"; echo "I5_JOB_JOBMSGQFL : " . $ret[I5_JOB_JOBMSGQFL] . "
"; } } $ret = i5_job_list_close($listHdl); ?>
Job Log List "PHPAIX")); if (is_bool($Hdlcon) && $Hdlcon == FALSE){ die(i5_errormsg());} $listHdl = i5_jobLog_list(); if (is_bool($listHdl)) die(i5_errormsg()); else echo "List
"; $a= 0; $ret = true; while($ret && $a < 2){ echo "Message $a
"; $ret = i5_jobLog_list_read($listHdl); $a ++; if (is_bool($ret)) die(i5_errormsg()); else { print_r($ret);echo "
data : ". $ret[I5_LOBJ_MSGDTA] . "
"; } } $ret = i5_jobLog_list_close($listHdl); if (is_bool($ret)) die(i5_errormsg()); else { print_r($ret);echo "
data : ". $ret[I5_LOBJ_MSGDTA] . "
"; ?>
332
API Reference
Data Areas "; $ret = i5_data_area_write("eacdemo/MYDTA", "'coucou'"); if ($ret) echo "3.It works!
"; $ret = i5_data_area_read("eacdemo/MYDTA", 2, 4); if ($ret) echo "4.It works!: ", $ret, "
"; $ret = i5_data_area_read("eacdemo/MYDTA"); if ($ret) echo "5.It works!: ", $ret, "
"; $ret = i5_data_area_write("eacdemo/MYDTA", "'lina'", 5, 45); if ($ret) echo "6.It works!
"; $ret = i5_data_area_read("eacdemo/MYDTA", 1, 5); if ($ret) echo "7.It works!: ", $ret, "
"; $ret = i5_data_area_read("eacdemo/MYDTA"); if ($ret) echo "8.It works!: ", $ret, "
"; $ret = i5_data_area_delete("eacdemo/MYDTA"); if ($ret) echo "9.It works!
"; ?>
Spooled Files Connect fail"); echo "
================
"; echo "
connected."; $spool = i5_spool_list(array("username"=>"lina"),$conn); if ($spool) { $count = 0; while (($a = i5_spool_list_read($spool)) && ($count <= 2)) { echo "
================
"; var_dump($a); echo "
data {$count}:
"; $data = i5_spool_get_data($a['SPLFNAME'], $a['JOBNAME'], $a['USERNAME'], $a['JOBNBR'], $a['SPLFNBR']); if (is_bool($data)) var_dump(i5_error()); var_dump($data); $count++; } i5_spool_list_close($spool); } else echo "No spool today."; i5_close($conn); XII. Object Listing $conn = i5_connect($connect, $user, $pass); if (!$conn) die("
Connect fail"); echo "
================
"; echo "
connected.
"; $objects = i5_objects_list("EACDEMO", "*ALL", "*PGM"); if ($objects) echo "1.It works!
"; $HdlObj = $objects; $objects = i5_objects_list_read($HdlObj); if (!is_bool($objects)) { echo "2.It works!
"; print_r($objects); echo "
"; } $continue = true;
333
Zend Server 5 for IBM i Reference Manual
$count = 0; while($continue) { $objects = i5_objects_list_read($HdlObj); if (is_bool($objects) && $objects == FALSE ) $continue = false; else { echo "3.It works!
"; print_r($objects); echo "
"; } $count ++; if ($count == 2) break; } $objects = i5_objects_list_close($HdlObj); if (is_bool($objects) && $objects == FALSE) $continue = false; else echo "4.It works!
"; ?>
334
API Reference
PCML Program Call - PCML Description Used in the PHP Program
S1:"; var_dump($S1_Value); echo "
S2:"; var_dump($S2_Value); echo "
CH10:"; var_dump($CH10_Value); echo "
CH11:"; var_dump($CH11_Value); echo "
CH12:"; var_dump($CH12_Value); echo "
CH13:"; var_dump($CH13_Value); echo "
Code:"; var_dump($Code_Value); echo "
Pack:"; var_dump($Pack); ?>
336
API Reference
PCML Program Call 2 - PCML File External to PHP Program
S1:"; var_dump($S1_Value); echo "
S2:"; var_dump($S2_Value); echo "
CH10:"; var_dump($CH10_Value); echo "
CH11:"; var_dump($CH11_Value); echo "
CH12:"; var_dump($CH12_Value); echo "
CH13:"; var_dump($CH13_Value); echo "
Code:"; var_dump($Code_Value); echo "
Pack:"; var_dump($Pack); ?>
337
Zend Server 5 for IBM i Reference Manual
List of an RPG Program, "TESTSTRUC", Called by the PCML Sample Programs D S1
DS D ZOND 1 10S 5 D pack1 11 20P 5 D alph1 21 30 D S2 DS D ZOND2 1 10S 5 D pack2 11 20P 5 D pack3 21 30P 5 D alph2 31 50 D SDS D $PGM 1 10 D $LIB 81 90 D $JOB 244 253 D $USER 254 263 D $JOBNM 264 269 D INFDS DS D KEY 369 369 D PAGRRN 378 379B 0 D* D F03 C CONST(X'33') C*------------------------------------------------------------------****************** C *ENTRY PLIST C PARM CODE 10 C PARM S1 C PARM S2 C PARM PACK 1 1 C PARM ch10 19 C PARM ch11 20 C PARM ch12 29 C PARM ch13 33 ********************** C MOVEL 'HELLO' CODE C Z-SUB 0.5 PACK C eval ch10 = *all'A' C eval ch11 = *all'B' C eval ch12 = *all'ZX' C eval ch13 = *all'5' C eval ZOND = 0 - zond C eval pack1 = 0 - pack1 C eval alph1 ='alph1' C - service side eval ZOND2 = 0 - zond2 C eval pack2 = 0-pack2 C eval pack3 =0 - pack3 C eval alph2 ='alph2' C* C SETON LR C RETURN
338
API Reference
Web Services conn = i5_connect('127.0.0.1', 'user', 'password'/*, $connection_parameters*/); if (!is_resource($this->conn)) { throw new SoapFault('i5_program_service', 'Connection to i5 server failed, use i5_errormsg() to get the failure reason'); } } public function service_for_i5_program($var_0, $var_1) { $description = Array ( array ('Name' => 'code', 'IO' => I5_INOUT, 'Type' => I5_TYPE_CHAR, 'Length' => '10'), array ('Name' => 'name', 'IO' => I5_INOUT, 'Type' => I5_TYPE_CHAR, 'Length' => '10')); $prog = i5_program_prepare('eacdemo/teststp2', $description, $this->conn); if (is_resource($prog)) { /* Execute Program */ $params = array ( 'code' => $var_0, 'name' => $var_1); $retvals = array( 'code' => 'ret_val_1', 'name' => 'ret_val_2'); $ret = i5_program_call($prog, $params, $retvals) ; if ($ret === true) { $ret = array($ret_val_1, $ret_val_2); return $ret; } else { throw new SoapFault('i5_program_service', 'Failed to call the program, use i5_errormsg() to get the failure reason'); } if (!i5_program_close ($prog) ) { throw new SoapFault('i5_program_service', 'Failed to free program resource handle, use i5_errormsg() to get the failure reason'); } } else { throw new SoapFault('i5_program_service', 'Program prepare failed, use i5_errormsg() to get the failure reason'); } } function __destruct() { if (!i5_close($this->conn)) { // Failed to disconnect from i5 server, use i5_errormsg() to get the failure reason } } } ini_set('soap.wsdl_cache_enabled', '0'); $server = new SoapServer('zend.wsdl'); $server->setClass('i5_program_service'); $server->handle();
339
Zend Server 5 for IBM i Reference Manual
?>
Web Services - Client Side service_for_i5_program('111', ' ')); } catch (SoapFault $exception) { echo $exception; } ?
340
API Reference
IBM i Toolkit Templates Zend Studio IDE for i5 comes complete with the following code templates containing i5 PHP API Toolkit functions: I5 Template
Explanation
i5ActiveJobs
Enables retrieving the system's active jobs, it: 1. Connects to i5 server 2. Opens active job list 3. Gets array for an active job entry 4. Closes handle received from i5_job_list function 5. Closes connection to i5 server
i5Connect
Enables connecting to the i5 server, it: 1. Connects to i5 server 2. Closes connection to i5 server
i5DataAreaCreate
Creates the data area, it: 1. Connects to i5 server 2. Creates data area of given size 3. Closes connection to i5 server
i5DataAreaDelete
Enables deleting the data area, it: 1. Connects to i5 server 2. Deletes data area 3. Closes connection to i5 server
i5DataAreaRead
Enables reading from a data area, it: 1. Connects to i5 server 2. Reads from data area 3. Closes connection to i5 server
i5DataAreaWrite
Enables reading from a data area, it: 1. Connects to i5 server 2. Reads from the data area 3. Closes connection to i5 server
i5DtaqReceive
Enables reading data from the data queue without key, it: 1. Connects to i5 server 2. Reads data from the data queue without key 3. Closes connection to i5 server
i5DtaqReceiveKey
Enables reading data from the data queue with key, it:
341
Zend Server 5 for IBM i Reference Manual
I5 Template
Explanation 1. Connects to i5 server 2. Reads data from the data queue with key 3. Closes connection to i5 server
i5DtaqSend
Enables putting data to the data queue without key, it: 1. Connects to i5 server 2. Puts data to the data queue without key 3. Closes connection to i5 server
i5DtaqSendKey
Enables putting data into the data queue without a key, it 1. Connects to i5 server 2. Puts data to the data queue without key 3. Closes connection to i5 server
i5JobLogs
Enables retrieving job log entries, it: 1. Connects to i5 server 2. Opens job log 3. Gets array for a job log entry 4. Closes handle received from i5_jobLog_list function 5. Closes connection to i5 server
i5ObjectListing
Enables getting an array with the message element for an object list entry, it: 1. Connects to i5 server 2. Opens object list 3. Gets for a object list entry 4. Closes handle received from i5_objects_list function 5. Closes connection to i5 server
i5Program
Enables calling a program and accept results from it, it: 1. Connects to i5 server 2. Opens a program or service procedure and prepares it to be run 3. Calls the program and optionally accepts results 4. Free program resource handle 5. Closes connection to i5 server
i5ProgramService
Creates Web Services class enabling invoking an RPG program, it: 1. Connects to i5 server 2. Opens a program or service procedure and prepares it to be
342
API Reference
I5 Template
Explanation run 3. Calls the program and optionally accepts results 4. Free program resource handle 5. Closes connection to i5 server
i5Spool
Enables getting spool file data from the queue and getting the data from the spool file, it: 1. Connects to i5 server 2. Creates an pool file lists, of certain output queue or for all queues 3. Gets spool file data from the queue 4. Get the data from the spool file 5. Free spool list resource 6. Closes connection to i5 server
i5UserSpaceCreate
Creates a new user space object, it: 1. Connects to i5 server 2. Creates new user space object 3. Closes connection to i5 server
i5UserSpaceDelete
Enables deleting a user space object, it: 1. Connects to i5 server 2. Deletes user space object 3. Closes connection to i5 server
i5UserSpaceGet
Retrieves user space data, it: 1. Connects to i5 server 2. Opens a user space and prepares it to be run 3. Retrieves user space data 4. Closes connection to i5 server
i5UserSpacePut
Enables to add user space data, it: 1. Connects to i5 server 2. Opens a user space and prepares it to be run 3. Adds user space data 4. Closes connection to i5 server
343
Zend Server for IBM i Installation Guide The IBM i Installation guide includes the following information:
Installing Zend Server for IBM i •
Uninstalling Zend Server for IBM i
•
Choosing Which Distribution to Install for IBM i
•
Silent Installation
•
Interactive Installation
•
MySQL Installation
•
Zend Server Extensions
•
Post Installation Instructions
Welcome to Zend Server for IBM i •
Registration
Zend Server for IBM i Setup Menu •
Sign-On
•
Main menu
•
Change Password
•
Update using PTFs menu
•
Run Support Tool
•
Service Management
•
MySQL Management menu
•
5250 Bridge Management menu
344
Zend Server for IBM i Installation Guide
Installing Zend Server for IBM i There are two installation modes, Silent, Interactive and Windows-Based. After Installation, Zend Server for IBM i users benefit from access to Zend Server's regular Updates and Security Fixes. Note: If you have a previously installed version of Zend Server for IBM i, see the instructions under 'Upgrading Zend Server for IBM i', below.
Installation Directories The Zend Server is installed in the following folder on your server :
IBM i: /usr/local/zendsvr
/www/zendsvr
345
Zend Server 5 for IBM i Reference Manual
Choosing Which Distribution to Install for IBM i Zend Server for IBM i is available, in several distribution formats: The distributions for all product versions are: 1. SAVF format - Download the package from zend.com. 2. Windows InstallShield format - Download the package from zend.com. (Available in GA)
IBM i Supported Operating Systems:
V5R4
V6R1
Choose the most suitable type of installation according to your operating system by selecting it from the table below. If you are unable to complete the installation, please refer to our Best Practices to see if these were already handled. Only if there is no article on the subject please see the Zend Support Center for further assistance. Package Name
Operating System
Installation Type
IBM i
V5R4
SAVF
V6R1
SAVF
V5R4
Windows InstallShield (Available in GA)
V6R4
Windows InstallShield (Available in GA)
346
Zend Server for IBM i Installation Guide
Silent Installation The following procedure describes how to install Zend Server in Silent Mode. The silent mode performs the complete installation without an installation interface To run a silent installation: 1. Download the installation package. Create a SAVF in QGPL under the name ZSVRSAVF. 2. Log on to the IBM i system with a user profile of *SECOFR user class with all special authorities. Create a SAVF in QGPL under the name ZSVRSAVF. This can be done by running the following command: CRTSAVF FILE(QGPL/ZSVRSAVF) TEXT(`Zend Server product save file') 3. Transfer the package by binary FTP to the SAVF ZSVRSAVF in QGPL. This can be done by executing the following steps: a. Verify that FTP is running on your IBM i system by running the following command and looking for 'FTP' or '21' in the Local Port column: NETSTAT *CNN
b. Open a command prompt and change directory to the directory that contains the files you extracted from the ZIP file. c.
Run the FTP command, specifying the name of your i5/OS system. e.g:
ftp IBM i_system_name/TCP address
d. If requested, enter a valid user profile and password. Enter the bin command to specify a binary transfer. e. Transfer the save file to the IBM i system by running the following command: put zsvrsavf.savf
4. When the SAVF is loaded into the IBM i QGPL library, return to your 5250 session and run the following command: SBMJOB CMD(RSTLICPGM LICPGM(ZSVRPI) DEV(*SAVF) SAVF(QGPL/ZSVRSAVF))
Zend Server for IBM i will be automatically installed without interactive dialogs being displayed. Note: The silent installation will not install the MySQL Database. For information about Uninstalling, see Uninstalling Zend Server for IBM.
347
Zend Server 5 for IBM i Reference Manual
Interactive Installation To run an interactive installation: 1. Download the installation package. 2. Log on to the IBM i system with a user profile of *SECOFR user class with all special authorities. 3. Create a SAVF in QGPL under the name ZSVRSAVF. This can be done by running the following command: CRTSAVF FILE(QGPL/ZSVRSAVF) TEXT(`Zend Server product save file')
4. Transfer the package by binary FTP to the SAVF ZSVRSAVF in QGPL. This can be done by executing the following steps: a. Verify that FTP is running on your IBM i system by running the following command and looking for 'FTP' or '21' in the Local Port column: NETSTAT *CNN
b. Open a command prompt and change directory to the directory that contains the files you extracted from the ZIP file. c.
Run the FTP command, specifying the name of your i5/OS system. e.g:
ftp IBM i_system_name/TCP address
b. If requested, enter a valid user profile and password. c.
Enter the bin command to specify a binary transfer.
d. Transfer the save file to the IBM i system by running the following command: put zsvrsavf.savf
6. When the SAVF is loaded into the IBM i QGPL library, return to your 5250 session and run the following command: RSTLICPGM LICPGM(21ZSVRPI) DEV(*SAVF) SAVF(QGPL/ZSVZRSAVF)
The installation screens will load automatically.
348
Zend Server for IBM i Installation Guide
Restore Licensed Program (RSTLICPGM)
Type choices, press Enter.
Product . . . . . . . . . . . . > 2ZSVRPI
Character value
Device . . . . . . . . . . . . . > *SAVF
Name, *SAVF
+ for more values Optional part to be restored . . *BASE
*BASE, 1, 2, 3, 4, 5, 6, 7...
Type of object to be restored . *ALL
*ALL, *PGM, *LNG
Language for licensed program . *PRIMARY
Character value, *PRIMARY...
Output . . . . . . . . . . . . . *NONE
*NONE, *PRINT
Release . . . . . . . . . . . . *FIRST
Character value, *FIRST
Replace release . . . . . . . . *ONLY Save file . . . . . . . . . . . zsvrsavf Library . . . . . . . . . . .
QGPL
Character value, *ONLY, *NO Name Name, *LIBL, *CURLIB
Restore Licensed Program Screen Press Enter to start running the installation. The installation welcome screen will appear. Zend Technologies Ltd. - Welcome System: I5QA2 Please read the documentation and Trial License Agreement.
You are about to install Zend Server product.
This installation procedure will create
349
Zend Server 5 for IBM i Reference Manual
o ZENDADMIN and ZS5250DEMO User Profiles
o ZENDSVR Zend Server Library
o zendsvr directory will be placed under /usr/local
o Auto start jobs in ZENDSVR subsystem
Bottom F3=Exit Enter=Accept Copyright Zend Technologies LTD (2009) The Installation welcome screen contains details of what the installation procedure contains. Press Enter to continue to the license agreement screen. Zend Technologies Ltd. - License System: I5QA2 ZEND SUBSCRIPTION AGREEMENT
Zend Server
350
Zend Server for IBM i Installation Guide
THIS SUBSCRIPTION AGREEMENT ("AGREEMENT") IS BETWEEN ZEND TECHNOLOGIES LTD. AND THE SUBSCRIBER TO, PURCHASER, LICENSEE OR USER OF, ZEND
PRODUCTS OR SERVICES. IMPORTANT: READ THESE TERMS CAREFULLY BEFORE DOWNLOADING THIS SOFTWARE. BY CLICKING THE "I ACCEPT" BUTTON, YOU (THE "SUBSCRIBER") ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, AND THAT YOU AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF YOU ARE ACTING ON BEHALF OF AN ENTITY, THEN YOU REPRESENT THAT YOU HAVE AUTHORITY TO ENTER INTO THIS AGREEMENT ON BEHALF OF THAT ENTITY. IF YOU DO NOT AGREE TO ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT, YOU MAY NOT USE THE SOFTWARE, AND IT IS YOUR RESPONSIBILITY TO TERMINATE THE DOWNLOAD PROCESS WITHOUT DOWNLOADING THE SOFTWARE.
1. Terms and Conditions.
1.1. Definitions "Confidential Information" is defined in Section 6.1. More... F3=Exit Enter=Accept
351
Zend Server 5 for IBM i Reference Manual
7. The program will be installed.
352
Zend Server for IBM i Installation Guide
Windows-Based Installation Zend Server for IBM i can be installed on your i5/OS server through your Windows Operating System, using interactive dialogs.
To install Zend Server for IBM i through Windows: 1. Download the Windows installation package. 2. Unzip the download file to your temp directory. 3. Double-click the Setup.exe file to start the installation. The Welcome Screen will appear. 4. Click Next. 5. Select whether to accept the terms of the agreement by selecting the relevant option. If you choose not to accept the agreement, the installation process will terminate. 6. Click Next to continue. 7. Enter the following details:
IBM i Server address - Your i5/OS server TCP/IP address.
User ID - Your IBM i login User ID.
Password - Your IBM i login password.
8. Mark the checkbox if you want MySQL to be installed on your IBM i server during the Zend Server for IBM i installation. The minimum supported IBM i version is V5R4. 9. Mark the relevant checkboxes for MySQL and/or Zend Platform 3.6.0 to be installed together with Zend Server for IBM i. Note: The minimum supported i5/OS version for MySQL installation is V5R4. In addition, if your server language is not English, you must sign on using a user profile that has CCSID set to 37 in order to install MySQL. To do this, run the command "CHGUSRPRF USRPRF(QSECOFR) CCSID(37)" in your i5/OS server. See the 'Testing your MySQL Connection using Zend Studio', section for more on connecting to the MySQL database. 10. Click Next. Details of the installation process will appear in the 'Installation log' window. 11. Once the installation process has completed, an installation details screen will appear:
353
Zend Server 5 for IBM i Reference Manual
Note: See the 'Getting Started' section for more information on logging in to your Zend Server for IBM i Web Administration GUI, and the Zend Server for IBM i Setup Tool section for more on using the Zend Server for IBM i Setup Tool. 11. Click Next. 12. An installation confirmation screen will appear. 13. Mark the checkbox to view the Zend Server for IBM i Release Notes. 14. Click Finish to exit.
354
Zend Server for IBM i Installation Guide
MySQL Installation This section describe how to install MySQL if you skip the MuSQL installation option during the interactive installation or used the silent installation To begin MySQL Installation select Option 6 ‘MySQL Management menu ’ from the Send server Service menu (GO ZENDSVR/ZSMENU):
MySQL installation (optional)
Press ENTER to start MySQL installation or press F3 to skip MySQL installation
F3=Exit MySQL Installation Option
Press Enter to start the MySQL installation or F3 to skip MySQL installation. Note: You can install the MySQL database later using the Setup Tool. To install MySQL following installation: 1. Open the Setup Tool by running the command go zendsvr/zcmenu in your i/OS emulator screen. 2. Select Option 6 - MySQL management menu. 3. You will be prompted to install the MySQL database. Note: MySQL must be installed by QSECOFR. If you pressed Enter and MySQL is already installed in the directory /usr/local/MySQL, the following prompt will appear: MySQL installation (optional)
MySql is already installed.
F3=Exit MySQL already installed
If this prompt has appeared, MySQL is already installed. Press F3 to finish the installation. If MySQL has not been previously installed, it will be installed now:
355
Zend Server 5 for IBM i Reference Manual
MySQL installation (optional)
MySQL is being installed and configured. Please wait ...
F3=Exit MySQL installation
A dialog will appear reminding you to set a password for the MySQL root user: PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: ./bin/mysqladmin -u root password 'new-password' ./bin/mysqladmin -u root -h ZEND825.ZEND.NET password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com Press ENTER to end terminal session. MySQL Instructions
In addition to the instructions in the dialog, the MySQL Daemon can later be stopped/started through the Zend Core Setup Tool.
To start/stop your MySQL Deamon (after the MySQL installation): 1. Open the Zend Core for i5 Setup Tool by running the following command: go zendsvr/zsmenu
2. Select Option 6 - MySQL Management Menu. 3. In the following screen, select Option 4 - Start MySQL daemon or Option 5 - Stop MySQL daemon. Press Enter to continue.
356
Zend Server for IBM i Installation Guide
MySQL installation (optional)
MySQL is installed in directory /usr/local/MySql and library ZMYSQL
F3=Exit MySQL Installation Confirmation
A confirmation message will appear stating the location of your MySQL installation. See the 'Testing your MySQL Connection using Zend Studio', section, below, for more on connecting to the MySQL database. Press F3 to finish and exit the installation process.
Testing your MySQL Connection using Zend Studio If you installed MySQL, you can use Zend Studio in order to test your MySQL connection and access your database. Note: See http://www.zend.com/en/products/studio/for-i5os for more on Zend Studio for i/OS.
To test your MySQL connection: 1. Open Zend Studio. 2. From Studio's File Manager, click the SQL tab. 3. Right-click and select the Add SQL Server option. The Add SQL Server dialog will appear. 4. Enter the SQL Server Settings in the fields. The settings include:
Server Type - Select MySQL.
Server Name (Alias) - Enter a server name. This will appear on the SQL Tree (of the File Manager).
Host Name/IP - Enter your server address.
Port - When you choose a Server Type, the default port appears in this field automatically.
Database Name - Enter 'mysql'.
User Name - Enter the default password 'root'.
357
Zend Server 5 for IBM i Reference Manual
Password - Leave the password field blank.
5. Click Test to attempt to connect to the SQL Server using the settings and connections currently entered in the Add SQL Server dialog box. If the connection is successful, a 'Connection Successful' dialog will appear. 6. Click OK. Your SQL Server will be added to the SQL tab, and you will be able to view and access the tables contained in it.
See the Zend Studio for i/OS User Guide for more information. Note: To uninstall MySQL: 1. Stop the ZMYSQL subsystem. 2. Delete ZMYSQL library. 3. Remove the /usr/local/mysql-5.0.45-i5os-power-64bit directory. 4. Remove the /usr/local//mysqldata directory. 5. Remove the /usr/local/mysql link. See http://dev.mysql.com/doc/refman/5.0/en/installation-i5os.html for more information.
358
Zend Server for IBM i Installation Guide
Uninstalling Zend Server for IBM i In order to save your current Zend Server for IBM i product library and files installed on your server, follow the installation steps detailed in the section "Upgrading Zend Server for IBM i", above.
To uninstall Zend Server for IBM i: 1. Sign on a 5250 session to your IBM i system, using a user profile of *SECOFR user class with all special authorities. 2. Run the following Delete Licensed Program (DLTLICPGM) command to uninstall Zend Server for IBM i: DLTLICPGM LICPGM(2ZSVRPI)
Once the programme has been uninstalled, the following message will be displayed: ”r;*PGM objects for product 2ZSVRPI option *BASE release V5R4M0 deleted. Objects for product 2ZSVRPI option *ALL release *ONLY deleted”. Note: The uninstaller deletes Zend Server for IBM i product library and files and creates a copy of the Zend Server for IBM i directories in /usr/local/ZendSvr+timestamp directory.
359
Zend Server 5 for IBM i Reference Manual
Post Installation This section includes the following Post Installation instructions:
360
Package Setup and Control Scripts IBM i
Ports and Services for IBM i
Installed Components for IBM i
Upgrading Zend Server for IBM i
Updating Zend Server for IBM i
Zend Server for IBM i Installation Guide
Package Setup and Control Scripts IBM i Package setup and control scripts, refers to the management of the different components included in Zend Server for IBM i. A list of the components that are installed and running on your system can be found in the Administration Interface in Server Setup | Components. Which components are installed depends on the chosen installation method, and product version.
Starting Zend Components on IBM i The Zend Server Service menu allows to control the Zend components that come with Zend Server for IBM i. To control the Apache webserver:
Select Option 5 and choose Stop/Start/Restart Apache webserver
You can also use IBM's "Web Administration for i5/OS" which will be running on port 2001 (http://