Skip to content

Commit 09e8121

Browse files
committed
update samles. With SWIG 4.1, there is not any php wrapper file anymore.
1 parent f0f8601 commit 09e8121

21 files changed

+141
-24
lines changed

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+
?>

0 commit comments

Comments
 (0)