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