Developing PHP Applications for IBM Database Servers
Total Page:16
File Type:pdf, Size:1020Kb
Front cover Developing PHP Applications for IBM Data Servers Develop and deploy Web solutions using PHP and IBM data servers See PHP with DB2, Informix IDS, and Cloudscape examples Port PHP applications from MySQL to DB2 Whei-Jen Chen Holger Kirstein Daniel Krook Kiran H Nair Piotr Pietrzak ibm.com/redbooks International Technical Support Organization Developing PHP Applications for IBM Data Servers May 2006 SG24-7218-00 Note: Before using this information and the product it supports, read the information in “Notices” on page xi. First Edition (May 2006) This edition applies to DB2 UDB Version 8.2, Informix IDS Version 10, PHP Versions 4 and 5, Apache 1.3, and Apache 2. © Copyright International Business Machines Corporation 2006. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Figures . vii Tables . ix Notices . xi Trademarks . xii Preface . xiii The team that wrote this redbook. xiii Acknowledgement. xv Become a published author . xvi Comments welcome. xvi Chapter 1. Technology overview . 1 1.1 Web application environment . 2 1.1.1 Web application advantages . 2 1.1.2 Web application challenges . 3 1.1.3 The state of the Web application world . 4 1.1.4 Web application components . 4 1.2 IBM data servers . 5 1.2.1 DB2 data server . 5 1.2.2 Informix database server family . 8 1.2.3 Cloudscape . 10 1.3 HTTP Servers . 11 1.3.1 Apache HTTP Server . 12 1.3.2 IBM HTTP Server . 15 1.3.3 Which Web server do I choose? . 17 1.4 PHP . 18 1.5 Database interfaces with PHP. 22 1.5.1 DB2 and Cloudscape . 22 1.5.2 Informix IDS database extensions . 24 1.6 Zend products . 27 Chapter 2. Sample scenario description. 31 2.1 Application requirements. 33 2.1.1 Customer interface functional requirements . 35 2.1.2 Dealer interface functional requirements . 45 2.1.3 Non-functional requirements of the entire application. 52 2.2 Data model . 53 © Copyright IBM Corp. 2006. All rights reserved. iii 2.2.1 Tables . 54 2.3 Application design . 56 2.3.1 Controller components . 57 2.3.2 View pages . 59 2.3.3 Domain objects . 60 2.3.4 Database adapters . 67 2.3.5 Conclusion . 71 2.4 Application installation. 72 Chapter 3. Zend installation and configuration . 75 3.1 Zend Core for IBM. 76 3.1.1 Installation: Linux . 76 3.1.2 Installation: Windows . 79 3.1.3 Sample application . 81 3.2 Zend Studio . 83 3.2.1 Installation . 83 3.2.2 Configuration. 85 3.2.3 Debugger . 89 Chapter 4. PHP application development with DB2. 95 4.1 Application environment setup . 96 4.1.1 Lab environment description . 96 4.1.2 User IDs and group . 97 4.1.3 Database server installation and configuration . 98 4.1.4 Apache and PHP installation and configuration . 102 4.1.5 Environment verification . 110 4.2 Using PHP with DB2 database . 113 4.2.1 ibm_db2 . 113 4.2.2 PDO_IBM/PDO_ODBC. 139 4.2.3 Unified ODBC . 161 4.2.4 Porting PHP applications from Unified ODBC to ibm_db2 . 169 4.3 Troubleshooting DB2 - PHP applications . 170 4.3.1 Taking CLI trace . 170 4.3.2 db2diag.log . 174 4.3.3 Tools for monitoring, tuning, and troubleshooting . 175 4.3.4 Getting the best out of DB2 from PHP . 183 4.4 PHP application and DB2 for z/OS . 184 Chapter 5. PHP applications with Informix database servers. 187 5.1 Application environment setup . 188 5.1.1 Lab application environment . 189 5.1.2 Installing IBM Informix IDS V10.00 on Linux. 189 5.1.3 Installing the Apache Web server . 198 5.1.4 Installing the Informix client and connectivity . 202 iv Developing PHP Applications for IBM Data Servers 5.1.5 Setting up PHP with multiple Informix IDS interfaces . 203 5.1.6 Installation verification. 217 5.2 Application development with Informix IDS . 227 5.2.1 Connection to the database . 227 5.2.2 Static and dynamic SQL statements in PHP. 232 5.2.3 Cursor and result set. 247 5.2.4 Complex data types . 269 5.2.5 Working with stored procedures and user defined functions . 276 5.2.6 BLOB and SBLOB data types . 303 5.2.7 Error handling . 315 5.2.8 Transactions and isolation level . 325 5.2.9 PHP and Informix XPS SQL extensions . 333 5.3 Optimization . 341 5.4 Apache, PHP, and Informix IDS on Windows.