Skip to content

Commit

Permalink
Merge pull request #5 from griddb/php8
Browse files Browse the repository at this point in the history
PHP8
  • Loading branch information
AnggaSuherman authored Mar 4, 2022
2 parents fdb10c9 + bd6764a commit 8388342
Show file tree
Hide file tree
Showing 39 changed files with 364 additions and 172 deletions.
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,56 @@ GridDB PHP Client

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

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

## Operating environment

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

OS: CentOS 7.8(x64)
SWIG: 4.0.0
OS: CentOS 7.9(x64)
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
GCC: 4.8.5
PHP: 7.4.7
GridDB Server: 4.5 (CE)
GridDB C Client: 4.5 (CE)
PHP: 8.0/8.1
GridDB Server: 4.6 (CE)
GridDB C Client: 4.6 (CE)

OS: CentOS 8.5(x64)
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
GCC: 8.3.1
PHP: 8.0/8.1
GridDB Server: 4.6 (CE)
GridDB C Client: 4.6 (CE)

OS: Ubuntu 18.04(x64)
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
GCC: 7.5.0
PHP: 8.0/8.1
GridDB Server: 4.6 (CE)
GridDB C Client: 4.6 (CE)

OS: Ubuntu 20.04(x64)
SWIG: 4.1.0 (commit: d22b7dfaea1f7abd4f3d0baecc1a1eddff827561)
GCC: 10.3.0
PHP: 8.0/8.1
GridDB Server: 4.6 (CE)
GridDB C Client: 4.6 (CE)

## QuickStart
### Preparations

Install SWIG as below.

$ wget https://prdownloads.sourceforge.net/swig/swig-4.0.0.tar.gz
$ tar xvfz swig-4.0.0.tar.gz
$ cd swig-4.0.0
$ git clone https://github.com/swig/swig.git
$ cd swig
$ git checkout d22b7dfaea1f7abd4f3d0baecc1a1eddff827561
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

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

Install PHP7.4.7 and GridDB C Client.
Install PHP 8 and GridDB C Client.

Set LIBRARY_PATH.

Expand All @@ -46,8 +65,6 @@ Set LIBRARY_PATH.

$ make

2. Include 'griddb_php_client.php' in PHP.

### How to run sample (with Command Line)

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

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

1. Store griddb_php_client.php and sample/sample1_web.php in /var/www/html.
1. Store sample/sample1_web.php in /var/www/html.

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

Expand Down
5 changes: 4 additions & 1 deletion sample/BlobData.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_one('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
7 changes: 5 additions & 2 deletions sample/Connect.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down Expand Up @@ -38,4 +41,4 @@
echo($e->getErrorMessage($i)."\n");
}
}
?>
?>
5 changes: 4 additions & 1 deletion sample/ContainerInformation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/ContainerNames.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/CreateCollection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
7 changes: 5 additions & 2 deletions sample/CreateIndex.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down Expand Up @@ -31,7 +34,7 @@
}

// Create an index
$col->createIndex("count", IndexType::HASH, "hash_index");
$col->createIndex("count", IndexType::HASH);
echo("Create Index\n");
echo("success!\n");
} catch (GSException $e) {
Expand Down
5 changes: 4 additions & 1 deletion sample/CreateTimeSeries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/GetRow.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/PutRow.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
57 changes: 57 additions & 0 deletions sample/PutRows.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

$containerName = "SamplePHP_PutRows";
$rowCount = 5;
$rowArray = [];

try {
// Get GridStore object
$gridstore = $factory->getStore(["host" => $argv[1],
"port" => (int)$argv[2],
"clusterName" => $argv[3],
"username" => $argv[4],
"password" => $argv[5]]);

// Create a collection
$conInfo = new ContainerInfo(["name" => $containerName,
"columnInfoArray" => [["id", Type::INTEGER],
["productName", Type::STRING],
["count", Type::INTEGER]],
"type" => ContainerType::COLLECTION,
"rowKey" => true]);

$col = $gridstore->putContainer($conInfo);
echo("Create Collection name=$containerName\n");

// Register multiple rows
// (1)Get the container
$col1 = $gridstore->getContainer($containerName);
if ($col1 == null) {
echo("ERROR Container not found. name=$containerName\n");
}

// Register multiple rows
for ($i = 0; $i < $rowCount; $i++) {
$row = [];
array_push($row, $i, "dvd", 10*$i);
array_push($rowArray, $row);
}
$col1->multiPut($rowArray);

echo("Put rows\n");
echo("success!\n");
} catch (GSException $e) {
for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
echo("\n[$i]\n");
echo($e->getErrorCode($i)."\n");
echo($e->getLocation($i)."\n");
echo($e->getErrorMessage($i)."\n");
}
}
?>
5 changes: 4 additions & 1 deletion sample/RemoveRowByRowkey.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/RemoveRowByTQL.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/TQLAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/TQLSelect.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
7 changes: 5 additions & 2 deletions sample/TQLTimeseries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down Expand Up @@ -105,4 +108,4 @@
echo($e->getErrorMessage($i)."\n");
}
}
?>
?>
5 changes: 4 additions & 1 deletion sample/TimeSeriesRowExpiration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/UpdateRowByTQL.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
7 changes: 5 additions & 2 deletions sample/sample1.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
<?php
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/sample1_web.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$data = "";
if (isset($_POST["address"]) && isset($_POST["port"]) && isset($_POST["cluster"]) &&
Expand Down
5 changes: 4 additions & 1 deletion sample/sample2.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
5 changes: 4 additions & 1 deletion sample/sample3.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
include('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
include_once('griddb_php_client.php');
}

$factory = StoreFactory::getInstance();

Expand Down
1 change: 0 additions & 1 deletion src/griddb.i
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
%ignore griddb::AggregationResult::AggregationResult;
%ignore griddb::QueryAnalysisEntry::QueryAnalysisEntry;
%ignore griddb::TimeSeriesProperties;
%ignore griddb::GSException::GSException;
%ignore griddb::TimestampUtils::TimestampUtils;

%include "gstype.i"
Expand Down
Loading

0 comments on commit 8388342

Please sign in to comment.