@@ -4,7 +4,7 @@ Interface for PHP to DB2 for z/OS, DB2 for LUW, DB2 for i.
4
4
5
5
## Pre-requisites
6
6
7
- The minimum PHP version supported by driver is PHP 7.3 and the latest version supported is PHP 8.1 .
7
+ The minimum PHP version supported by driver is PHP 7.3 and the latest version supported is PHP 8.2 .
8
8
9
9
## IBM i users
10
10
@@ -34,36 +34,48 @@ PHP, gcc, make, tar should be installed in your system.
34
34
35
35
You may not find gcc, make, tar in some of the docker containers (Example Amazon Linux2).
36
36
In such cases use below command to install gcc etc.
37
+
37
38
``` shell
38
39
yum install make gcc
39
40
```
40
41
## How to install php ibm_db2 extension in Linux/Mac.
41
- ```
42
- if IBM_DB_HOME and LD_LIBRARY_PATH environment variable not set then set them with installed CLIDRIVER.
43
- (say CLIDRIVER installed at "/home/user/clidriver")
44
42
43
+ If ` IBM_DB_HOME ` and ` LD_LIBRARY_PATH ` environment variable not set then set them with installed CLIDRIVER.
44
+ (say CLIDRIVER installed at ` /home/user/clidriver ` )
45
+
46
+ ``` shell
45
47
export IBM_DB_HOME=/home/user/clidriver
46
- export LD_LIBRARY_PATH=/home/user/clidriver/lib
47
- export PATH=/home/user/clidriver/bin:$PATH
48
+ export LD_LIBRARY_PATH=" ${IBM_DB_HOME} /lib"
49
+ export PATH=" ${IBM_DB_HOME} /bin" :$PATH
50
+ ```
51
+
52
+ In case of Docker (Example Amazon Linux2), execute ` db2level ` command in your command prompt. If any error comes then install
53
+ ` pam ` from package manager:
48
54
49
- In case of Docker(Example Amazon Linux2):
50
- execute 'db2level' command in your command prompt, If any error comes then install ' pam' from package manager.
51
- yum install pam
55
+ ``` shell
56
+ yum install pam
57
+ ```
52
58
53
- 1) pecl install ibm_db2
59
+ 1 . Install this extension:
60
+
61
+ ``` shell
62
+ pecl install ibm_db2
63
+ ```
54
64
55
- 2) Open the php.ini file in an editor of your choice. Edit the extension entry in the
56
- php.ini file in the <local_php_directory>/php/lib directory to reference the PHP driver:
57
- extension=ibm_db2.so
65
+ 2 . Open the ` php.ini ` file in an editor of your choice. Edit the extension entry in the
66
+ ` php.ini ` file in the ` <local_php_directory>/php/lib ` directory to reference the PHP driver:
67
+
68
+ ``` ini
69
+ extension =ibm_db2.so
70
+ ```
58
71
59
- 3) Ensure that the PHP driver can access the libdb2.so CLI driver file by
60
- setting the LD_LIBRARY_PATH variable for Linux and UNIX operating systems
61
- other than the AIX® operating system. For AIX operating system, you must set LIBPATH variable.
72
+ 3 . Ensure that the PHP driver can access the ` libdb2.so ` CLI driver file by
73
+ setting the ` LD_LIBRARY_PATH ` variable for Linux and UNIX operating systems
74
+ other than the AIX® operating system. For AIX operating system, you must set ` LIBPATH ` variable.
62
75
63
- 4) Optional: If the PHP application that is connecting to an IBM database server is running ini
64
- the HTTP server environment, add the LD_LIBRARY_PATH variable in the httpd.conf file.
76
+ 4 . Optional: If the PHP application that is connecting to an IBM database server is running ini
77
+ the HTTP server environment, add the ` LD_LIBRARY_PATH ` variable in the ` httpd.conf ` file.
65
78
66
- ```
67
79
## Prebuilt binaries for Windows
68
80
69
81
1 . Add the ` CLIDRIVER\bin ` path to the ` PATH ` environment variable like so (for a batch file):
@@ -75,50 +87,55 @@ In case of Docker(Example Amazon Linux2):
75
87
76
88
3. Open the `php.ini` file in an editor of your choice. Edit the extension entry in the
77
89
`php.ini` file in the `<local_php_directory>\php\lib` directory to reference the driver:
78
- ````
90
+
91
+ ```ini
79
92
extension=php_ibm_db2
80
- ````
93
+ ```
81
94
82
95
## How to run sample program
83
96
84
- ### connect.php:-
97
+ Create a ` connect.php` script with the following content:
85
98
86
- ```
99
+ ```php
87
100
<?php
101
+
88
102
$database = 'dsn name';
89
103
$user = 'user';
90
104
$password = 'password';
91
105
$conn = db2_connect($database, $user, $password);
92
106
93
107
if ($conn) {
94
- echo " Connection succeeded." ;
108
+ echo ' Connection succeeded.' ;
95
109
db2_close($conn);
96
- }
97
- else {
98
- echo "Connection failed: " . db2_conn_errormsg();
110
+ } else {
111
+ echo 'Connection failed: ' . db2_conn_errormsg();
99
112
}
100
113
?>
114
+ ```
101
115
102
- To run the sample:- php connect.php
116
+ Run the sample program:
117
+
118
+ ``` shell
119
+ php connect.php
103
120
```
121
+
104
122
## How to build from source code in Linux or Mac
105
- ```
106
- Use the commands included in the source code:
107
- download Source code from https://pecl.php.net/package/ibm_db2
108
- a) Extract the source archive
109
- b) Run the following commands from the extracted directory:
110
- $ phpize --clean
111
- $ phpize
112
- $ ./configure --with-IBM_DB2=/home/user/clidriver
113
- $ make
114
- $ make install
115
- ```
123
+
124
+ 1 . Download Source code from https://pecl.php.net/package/ibm_db2
125
+ 2 . Extract the source archive
126
+ 3 . Run the following commands from the extracted directory:
127
+
128
+ ``` shell
129
+ phpize --clean
130
+ phpize
131
+ ./configure --with-IBM_DB2=/home/user/clidriver
132
+ make
133
+ make install
134
+ ```
116
135
# # How to build from source code in Windows
117
- ```
118
- Below blog mentiones how to build php ibm_db2 from source in windows.
119
- https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/Install_PHP_ibm_db2_Driver?lang=en
120
136
121
- ```
137
+ [This blog](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/Install_PHP_ibm_db2_Driver? lang=en)
138
+ mentions how to build php ibm_db2 from source in Windows.
122
139
123
140
# # Test suite
124
141
@@ -144,9 +161,10 @@ the amount of systems in the wild without a properly set QCCSID, but you
144
161
should do this anyways. To check and set QCCSID, run `WRKSYSVAL` from a 5250.
145
162
146
163
## Contributing:
147
- ```
148
- See CONTRIBUTING.md
149
164
150
- The developer sign-off should include the reference to the DCO in defect remarks(example below):
165
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md).
166
+ The developer sign-off should include the reference to the DCO in defect remarks, like in this example:
167
+
168
+ ```
151
169
DCO 1.1 Signed-off-by: Random J Developer <random@developer.org>
152
170
```
0 commit comments