Skip to content

Commit d37ed77

Browse files
committed
Added PHP 7.3 Support
1 parent 5e45477 commit d37ed77

16 files changed

+177
-96
lines changed

.travis.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
language: php
2+
3+
php:
4+
- '7.3'
5+
- '7.2'
6+
- '7.1'
7+
- '7.0'
8+
- '5.6'
9+
10+
install:
11+
- curl https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz | tar -xz
12+
- docker pull ibmcom/db2express-c
13+
- docker run --name db2 -p 60000:50000 -e DB2INST1_PASSWORD=password -e LICENSE=accept -d ibmcom/db2express-c db2start
14+
- docker ps -as
15+
- docker exec -it db2 su - db2inst1 -c "db2 create db sample"
16+
17+
before_script:
18+
# Ensure that DB2CLIINIPATH gets passed to the tests
19+
- echo 'variables_order = "EGPCS"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
20+
21+
script:
22+
- phpize
23+
- ./configure --with-IBM_DB2=$PWD/clidriver
24+
- make
25+
- |
26+
cat <<EOF > db2cli.ini
27+
[SAMPLE]
28+
Hostname=localhost
29+
Protocol=TCPIP
30+
Port=60000
31+
Database=sample
32+
EOF
33+
- cat db2cli.ini
34+
# Ensure that tests are not skipped (false positive) due to bad configuration
35+
- export IBM_DB2_TEST_SKIP_CONNECT_FAILURE=0
36+
# Ensure CLI can find the configuration
37+
- export DB2CLIINIPATH=$PWD
38+
# Ensure make returns non-zero when a test fails
39+
- export REPORT_EXIT_STATUS=1
40+
# Save the report so we can print it if a test fails
41+
- make test TESTS='-s report.txt'
42+
43+
after_failure:
44+
- cat report.txt

ibm_db2.c

Lines changed: 60 additions & 42 deletions
Large diffs are not rendered by default.

php_ibm_db2.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ extern zend_module_entry ibm_db2_module_entry;
3434
#include <stdio.h>
3535
#include <string.h>
3636
#include <stdlib.h>
37+
38+
#if !defined(_MSC_VER) || _MSC_VER >= 1600
39+
#include <stdint.h>
40+
#else
41+
42+
#ifdef _WIN64
43+
typedef int64_t intptr_t;
44+
typedef uint64_t uintptr_t;
45+
#else
46+
typedef int32_t intptr_t;
47+
typedef uint32_t uintptr_t;
48+
#endif
49+
#endif
50+
3751
#include <sqlcli1.h>
3852

3953
/* Needed for backward compatibility (IS_INTERNED not defined prior to PHP-5.4) */

tests/connection.inc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ else {
3939
date_default_timezone_set('UTC');
4040

4141

42+
$skip_on_connect_failure = getenv("IBM_DB2_TEST_SKIP_CONNECT_FAILURE") !== FALSE ?
43+
getenv("IBM_DB2_TEST_SKIP_CONNECT_FAILURE") : true;
44+
45+
4246
// test connection ok
4347
$prepconn = db2_connect($database, $user, $password);
44-
if (!$prepconn) die('skip');
45-
db2_close($prepconn);
48+
if (!$prepconn) {
49+
if($skip_on_connect_failure) die("skip - Couldn't connect");
50+
}
51+
else {
52+
db2_close($prepconn);
53+
}
54+
55+
unset($skip_on_connect_failure);
4656

4757
?>

tests/escape.dat

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11

22
Original: Some random special characters:
3-
,
4-
, \ , ' , " .
3+
, , \ , ' , " .
54
db2_escape_string: Some random special characters:
6-
,
7-
, \ , ' , " .
5+
, , \ , ' , " .
86

97
Original: Backslash (\). Single quote ('). Double quote (")
108
db2_escape_string: Backslash (\). Single quote ('). Double quote (")

tests/test_001_ConnDb.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if ($conn) {
1313
db2_close($conn);
1414
}
1515
else {
16-
echo "Connection failed.";
16+
echo "Connection failed: " . db2_conn_errormsg();
1717
}
1818

1919
?>

tests/test_045_FetchArrayBinaryData.phpt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ require_once('connection.inc');
99

1010
$conn = db2_connect($db,$username,$password);
1111

12-
$orig = fopen("pic1.jpg", "rb");
13-
$new = fopen("pic1_out.jpg", "wb");
12+
$in_file = "pic1.jpg";
13+
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
1414

1515
$result = db2_exec($conn, "select photo_format, picture, length(picture) from emp_photo where photo_format='jpg' and empno='000130'");
1616
$row = db2_fetch_array($result);
17+
$out = "";
1718
if ($row) {
18-
fwrite($new, $row[1]);
19+
$out .= $row[1];
1920
}
2021

21-
$file0 = file_get_contents("pic1.jpg");
22-
$file1 = file_get_contents("pic1_out.jpg");
23-
24-
if(strcmp($file0, $file1) == 0) {
22+
if(strcmp($in, $out) == 0) {
2523
echo "The files are the same...good.";
2624
} else {
2725
echo "The files are not the same...bad.";
@@ -37,4 +35,4 @@ echo "\nIterated over $count rows.";
3735
?>
3836
--EXPECT--
3937
The files are the same...good.
40-
Iterated over 8 rows.
38+
Iterated over 8 rows.

tests/test_048_FetchArrayBinaryData.phpt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ require_once('connection.inc');
99

1010
$conn = db2_connect($db,$username,$password);
1111

12-
$orig = fopen("spook.png", "rb");
13-
$new = fopen("spook_out.png", "wb");
12+
$in_file = "spook.png";
13+
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
1414

1515
$result = db2_exec($conn, "SELECT picture, LENGTH(picture) FROM animal_pics WHERE name = 'Spook'");
1616
$row = db2_fetch_array($result);
17+
$out = "";
1718
if ($row) {
18-
fwrite($new, $row[0]);
19+
$out .= $row[0];
1920
}
2021

21-
$file0 = file_get_contents("spook.png");
22-
$file1 = file_get_contents("spook_out.png");
23-
24-
if(strcmp($file0, $file1) == 0) {
22+
if(strcmp($in, $out) == 0) {
2523
echo "The files are the same...good.";
2624
} else {
2725
echo "The files are not the same...bad.";

tests/test_080_ConnWrongDbAlias.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ if ($conn) {
1313
echo "??? No way.\n";
1414
}
1515
else {
16-
$err = db2_conn_error();
17-
echo $err."\n";
16+
echo var_dump(db2_conn_error());
1817
}
1918

2019
?>
2120
--EXPECTF--
22-
0800%d
21+
string(5) "%s"

tests/test_090_ConnmsgWrongDbAlias.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ else {
1919

2020
?>
2121
--EXPECTF--
22-
[IBM][CLI Driver] %s SQLSTATE=%d SQLCODE=-%d
22+
[IBM][CLI Driver] %s SQLCODE=-%d

0 commit comments

Comments
 (0)