Accessing DB2 from PHP

2013 年 2 月 14 日3920

Accessing DB2 from PHP Author: John O鈥橫ahony, Risaris Ltd

Accessing DB2 from PHP

Contents

1. Introduction .................................................................................................................................... 2

2. Prerequisites ................................................................................................................................... 2

3. Setup ............................................................................................................................................... 2

3.1. PHP .......................................................................................................................................... 2

3.2. Apache .................................................................................................................................... 2

Apache configuration ...................................................................................................................... 2

3.3. DB2 .......................................................................................................................................... 3

Populate DB2 Database ...................................................................................................................... 3

Set up ODBC Access ............................................................................................................................ 3

1. Discovery ......................................................................................................................................... 4

1.1. Web Service Creation using SOA Gateway ............................................................................. 4

1.2. Accessing the WSDL ................................................................................................................ 6

2. Accessing Web Service with PHP .................................................................................................... 8

2.1. Initial Setup ............................................................................................................................. 9

2.2. The Form ............................................................................................................................... 10

5.3 Code ............................................................................................................................................ 10

5.3 Query the database..................................................................................................................... 11

3. Conclusion ..................................................................................................................................... 12

4. Appendix ....................................................................................................................................... 12

Accessing DB2 from PHP Author: John O鈥橫ahony, Risaris Ltd

1. Introduction

In this tutorial we will show you how to build a PHP application to access DB2 via the SOA Gateway.

2. Prerequisites

It is assumed that you are running the 3 components, DB2, PHP and the SOA Gateway on Windows.

It is assumed you already have a SOA Gateway server and Control Centre installed. See here for

more info about installing the SOA Gateway.

3. Setup

3.1. PHP

Download the latest Windows binaries for PHP v5.x from the PHP downloads page, install it

according to the install.txt document in the PHP distribution library.

Enable the PHP SOAP Extension. The soap extension is shipped as part of PHP 5, but needs

to be enabled explicitly.

? If you downloaded the PHP source code and compiled it for your platform, you will

probably need to rebuild, because ext/soap is not enabled by default. Repeat your

previous build process, adding the --enable-soap option to the configure command.

? If you downloaded pre-compiled platform binaries, they have ext/soap compiled in, but

not loaded, so you will need to update your PHP configuration to do so. Edit you

0 0