Skip to content

Commit 8388342

Browse files
Merge pull request #5 from griddb/php8
PHP8
2 parents fdb10c9 + bd6764a commit 8388342

39 files changed

+364
-172
lines changed

README.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,56 @@ GridDB PHP Client
44

55
GridDB PHP Client is developed using GridDB C Client and [SWIG](http://www.swig.org/) (Simplified Wrapper and Interface Generator).
66

7-
The new PHP Client (0.8) brings improved usability.
8-
Main difference to the old PHP Client (0.5) is as below:
9-
- Put and get row data without C-based methods defined for each data-type
107

118
## Operating environment
129

1310
Building of the library and execution of the sample programs have been checked in the following environment.
1411

15-
OS: CentOS 7.8(x64)
16-
SWIG: 4.0.0
12+
OS: CentOS 7.9(x64)
13+
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
1714
GCC: 4.8.5
18-
PHP: 7.4.7
19-
GridDB Server: 4.5 (CE)
20-
GridDB C Client: 4.5 (CE)
15+
PHP: 8.0/8.1
16+
GridDB Server: 4.6 (CE)
17+
GridDB C Client: 4.6 (CE)
18+
19+
OS: CentOS 8.5(x64)
20+
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
21+
GCC: 8.3.1
22+
PHP: 8.0/8.1
23+
GridDB Server: 4.6 (CE)
24+
GridDB C Client: 4.6 (CE)
25+
26+
OS: Ubuntu 18.04(x64)
27+
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
28+
GCC: 7.5.0
29+
PHP: 8.0/8.1
30+
GridDB Server: 4.6 (CE)
31+
GridDB C Client: 4.6 (CE)
32+
33+
OS: Ubuntu 20.04(x64)
34+
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
35+
GCC: 10.3.0
36+
PHP: 8.0/8.1
37+
GridDB Server: 4.6 (CE)
38+
GridDB C Client: 4.6 (CE)
2139

2240
## QuickStart
2341
### Preparations
2442

2543
Install SWIG as below.
2644

27-
$ wget https://prdownloads.sourceforge.net/swig/swig-4.0.0.tar.gz
28-
$ tar xvfz swig-4.0.0.tar.gz
29-
$ cd swig-4.0.0
45+
$ git clone https://github.com/swig/swig.git
46+
$ cd swig
47+
$ git checkout d22b7dfaea1f7abd4f3d0baecc1a1eddff827561
48+
$ ./autogen.sh
3049
$ ./configure
3150
$ make
3251
$ sudo make install
3352

3453
Note: If CentOS, you might need to install pcre in advance.
3554
$ sudo yum install pcre2-devel.x86_64
3655

37-
Install PHP7.4.7 and GridDB C Client.
56+
Install PHP 8 and GridDB C Client.
3857

3958
Set LIBRARY_PATH.
4059

@@ -46,8 +65,6 @@ Set LIBRARY_PATH.
4665

4766
$ make
4867

49-
2. Include 'griddb_php_client.php' in PHP.
50-
5168
### How to run sample (with Command Line)
5269

5370
GridDB Server need to be started in advance.
@@ -72,7 +89,7 @@ GridDB Server need to be started in advance.
7289

7390
In the case of Web Server: Apache/2.4.6, please use the following steps.
7491

75-
1. Store griddb_php_client.php and sample/sample1_web.php in /var/www/html.
92+
1. Store sample/sample1_web.php in /var/www/html.
7693

7794
2. Store griddb_php_client.so in /usr/lib64/php/modules.
7895

sample/BlobData.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_one('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/Connect.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

@@ -38,4 +41,4 @@
3841
echo($e->getErrorMessage($i)."\n");
3942
}
4043
}
41-
?>
44+
?>

sample/ContainerInformation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/ContainerNames.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/CreateCollection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/CreateIndex.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

@@ -31,7 +34,7 @@
3134
}
3235

3336
// Create an index
34-
$col->createIndex("count", IndexType::HASH, "hash_index");
37+
$col->createIndex("count", IndexType::HASH);
3538
echo("Create Index\n");
3639
echo("success!\n");
3740
} catch (GSException $e) {

sample/CreateTimeSeries.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/GetRow.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/PutRow.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/PutRows.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
6+
7+
$factory = StoreFactory::getInstance();
8+
9+
$containerName = "SamplePHP_PutRows";
10+
$rowCount = 5;
11+
$rowArray = [];
12+
13+
try {
14+
// Get GridStore object
15+
$gridstore = $factory->getStore(["host" => $argv[1],
16+
"port" => (int)$argv[2],
17+
"clusterName" => $argv[3],
18+
"username" => $argv[4],
19+
"password" => $argv[5]]);
20+
21+
// Create a collection
22+
$conInfo = new ContainerInfo(["name" => $containerName,
23+
"columnInfoArray" => [["id", Type::INTEGER],
24+
["productName", Type::STRING],
25+
["count", Type::INTEGER]],
26+
"type" => ContainerType::COLLECTION,
27+
"rowKey" => true]);
28+
29+
$col = $gridstore->putContainer($conInfo);
30+
echo("Create Collection name=$containerName\n");
31+
32+
// Register multiple rows
33+
// (1)Get the container
34+
$col1 = $gridstore->getContainer($containerName);
35+
if ($col1 == null) {
36+
echo("ERROR Container not found. name=$containerName\n");
37+
}
38+
39+
// Register multiple rows
40+
for ($i = 0; $i < $rowCount; $i++) {
41+
$row = [];
42+
array_push($row, $i, "dvd", 10*$i);
43+
array_push($rowArray, $row);
44+
}
45+
$col1->multiPut($rowArray);
46+
47+
echo("Put rows\n");
48+
echo("success!\n");
49+
} catch (GSException $e) {
50+
for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
51+
echo("\n[$i]\n");
52+
echo($e->getErrorCode($i)."\n");
53+
echo($e->getLocation($i)."\n");
54+
echo($e->getErrorMessage($i)."\n");
55+
}
56+
}
57+
?>

sample/RemoveRowByRowkey.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/RemoveRowByTQL.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/TQLAggregation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/TQLSelect.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/TQLTimeseries.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

@@ -105,4 +108,4 @@
105108
echo($e->getErrorMessage($i)."\n");
106109
}
107110
}
108-
?>
111+
?>

sample/TimeSeriesRowExpiration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/UpdateRowByTQL.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/sample1.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
<?php
2-
include('griddb_php_client.php');
1+
<?php
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/sample1_web.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$data = "";
58
if (isset($_POST["address"]) && isset($_POST["port"]) && isset($_POST["cluster"]) &&

sample/sample2.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

sample/sample3.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
include('griddb_php_client.php');
2+
if (file_exists('griddb_php_client.php')) {
3+
// File php wrapper is generated with SWIG 4.0.2 and below
4+
include_once('griddb_php_client.php');
5+
}
36

47
$factory = StoreFactory::getInstance();
58

src/griddb.i

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
%ignore griddb::AggregationResult::AggregationResult;
2929
%ignore griddb::QueryAnalysisEntry::QueryAnalysisEntry;
3030
%ignore griddb::TimeSeriesProperties;
31-
%ignore griddb::GSException::GSException;
3231
%ignore griddb::TimestampUtils::TimestampUtils;
3332

3433
%include "gstype.i"

0 commit comments

Comments
 (0)