LoginSignup
0
0

More than 5 years have passed since last update.

DynamoDBLocalとAWS SDK for PHP2でごにょごにょする4 - delete

Last updated at Posted at 2015-03-02

次はDynamoDBLocalとAWS SDK for PHP2でごにょごにょする3 - putとgetで登録したデータをテーブルごと削除してみます。

環境


  • VirtualBox 4.3
  • ubuntu 14.04
  • PHP 5.5.9-1ubuntu4.5 (cli)

テーブル削除と確認


DeleteTable.class.php
<?php
require_once 'DynamoDB.class.php';
class DeleteTable {
    private $dynamo;
    public function __construct() {
        $this->dynamo = DynamoDB::conn();
    }

    public function execute() {
        $param = array(
            'TableName' => 'user'
        );

        $this->dynamo->deleteTable($param);

        // 確認
        $param = array(
            'TableName' => 'user'
        );

        try {
            $result = $this->dynamo->describeTable($param);
            var_dump($result);
        } catch (DynamoDbException $e) {
            print $e;
        }
    }
}
$deleteTable = new DeleteTable;
$deleteTable->execute();
$ php DeleteTable.class.php                                                                           
PHP Fatal error:  Uncaught Aws\DynamoDb\Exception\ResourceNotFoundException: AWS Error Code: ResourceNotFoundException, Status Code: 400, AWS Request ID: fdb831b7-f4e3-41b6-8025-4186edf6b7c3, AWS Error Type: client, AWS Error Message: Cannot do operations on a non-existent table, …

テーブルを削除した後に、テーブルの確認をしたことにより
「non-existent table」
が出力されました。

正しくテーブルが削除されたようです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0