revenuewire/dynamodb-orm
最新稳定版本:v2.0.7
Composer 安装命令:
composer require revenuewire/dynamodb-orm
包简介
RW Dynamo ORM
README 文档
README
composer require revenuewire/dynamodb-orm
Configuration
<?php if (APPLICATION_ENV == "local" || APPLICATION_ENV == "qa") { Model::configure(["region" => NETWORK_REGION, "endpoint" => 'http://dynamodb:8000']); } else { Model::configure(["region" => NETWORK_REGION]); }
Model
Manually create object class.
<?php use RW\DynamoDb\Model; class User extends Model { public static $tableName = 'user'; /** * DynamoDB Schema Definition */ public static $schema = [ "TableName" => "user", "AttributeDefinitions" => [ [ 'AttributeName' => 'id', 'AttributeType' => 'S', ] ], 'KeySchema' => [ [ 'AttributeName' => 'id', 'KeyType' => 'HASH', ] ], 'ProvisionedThroughput' => [ 'ReadCapacityUnits' => 5, 'WriteCapacityUnits' => 5, ], ]; }
Install DB
<?php require_once (__DIR__ . "/../vendor/autoload.php"); Model::configure(["region" => NETWORK_REGION]); $schemas = [ \Models\User::$schema, ]; echo "Install DBs..."; foreach ($schemas as $schema) { try { Model::$client->deleteTable([ "TableName" => $schema['TableName'] ]); } catch (Exception $e) {} Model::$client->createTable($schema); } echo "done\n";
Usage
Create
<?php $user = new User(); $user->id = "my-id"; $user->firstName = "hello"; $user->lastName = "world"; $user->save();
Find one and update
<?php $user = User::getById('my-id'); $user->lastName = "wood"; $user->save();
统计信息
- 总下载量: 4.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-08-29