|
| 1 | +<?php |
| 2 | + include('griddb_php_client.php'); |
| 3 | + |
| 4 | + $factory = StoreFactory::getInstance(); |
| 5 | + |
| 6 | + $containerName = "SamplePHP_Info"; |
| 7 | + |
| 8 | + try { |
| 9 | + // Get GridStore object |
| 10 | + $gridstore = $factory->getStore(["host" => $argv[1], |
| 11 | + "port" => (int)$argv[2], |
| 12 | + "clusterName" => $argv[3], |
| 13 | + "username" => $argv[4], |
| 14 | + "password" => $argv[5]]); |
| 15 | + |
| 16 | + // Create a collection container |
| 17 | + $conInfo = new ContainerInfo(["name" => $containerName, |
| 18 | + "columnInfoArray" => [["id", Type::INTEGER], |
| 19 | + ["productName", Type::STRING], |
| 20 | + ["count", Type::INTEGER]], |
| 21 | + "type" => ContainerType::COLLECTION, |
| 22 | + "rowKey" => true]); |
| 23 | + |
| 24 | + $col = $gridstore->putContainer($conInfo); |
| 25 | + echo("Sample data generation: Create Collection name=$containerName\n"); |
| 26 | + |
| 27 | + // Get container information |
| 28 | + // (1)Get container information |
| 29 | + $containerInfo = $gridstore->getContainerInfo($containerName); |
| 30 | + |
| 31 | + // (2)Display container information |
| 32 | + echo("Get containerInfo:\n name =".$containerInfo->name."\n"); |
| 33 | + |
| 34 | + if ($containerInfo->type == ContainerType::COLLECTION) { |
| 35 | + echo(" type=Collection\n"); |
| 36 | + } else { |
| 37 | + echo(" type=Timeseries\n"); |
| 38 | + } |
| 39 | + |
| 40 | + echo(" rowKeyAssigned=". (($containerInfo->rowKey) ? "true" : "false")."\n"); |
| 41 | + |
| 42 | + $count = sizeof($containerInfo->columnInfoArray); |
| 43 | + echo(" columnCount=$count\n"); |
| 44 | + |
| 45 | + for ($i = 0; $i < $count; $i++) { |
| 46 | + echo(" column (".$containerInfo->columnInfoArray[$i][0].", ".$containerInfo->columnInfoArray[$i][1].")\n"); |
| 47 | + } |
| 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