PHPackages                             reallywang/dynamo-db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. reallywang/dynamo-db

ActiveProject[Database &amp; ORM](/categories/database)

reallywang/dynamo-db
====================

DynamoDB操作封装

1.5(7y ago)0991MITPHPPHP &gt;=7.0.0

Since Feb 27Pushed 7y agoCompare

[ Source](https://github.com/RReallyWang/DynamoDB)[ Packagist](https://packagist.org/packages/reallywang/dynamo-db)[ RSS](/packages/reallywang-dynamo-db/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (1)Versions (9)Used By (1)

DynamoDB操作封装
============

[](#dynamodb操作封装)

像使用MySQL一样使用DynamoDB(Use DynamoDB as you would with MySQL)
禁止使用保留字，具体哪些是保留字可在包文件 DynamoDb.php 文件中查看，如果已经使用保留字的用户，请读下一条
保留字问题已在内部处理，使用者可以不用关心保留字问题（AWS不支持的地方此工具同样不支持，AWS支持的地方此工具已内部处理）

目录
--

[](#目录)

#### 1. [安装](#1)

[](#1-安装)

#### 2. [使用](#2)

[](#2-使用)

#### 3. [新增数据](#3)

[](#3-新增数据)

#### 4. [修改数据](#4)

[](#4-修改数据)

#### 5. [查询数据](#5)

[](#5-查询数据)

#### 6. [删除数据](#6)

[](#6-删除数据)

#### 7. [获取数量](#7)

[](#7-获取数量)

#### 8. [部分删除](#8)

[](#8-部分删除)

#### 9. [自增与自减](#9)

[](#9-自增与自减)

现在，开始
-----

[](#现在开始)

### 1. 安装

[](#1-安装-1)

```
composer require reallywang/dynamo-db

```

或是composer.json中require下添加

```
"reallywang/dynamo-db": "^1.4"

```

### 2. 使用

[](#2-使用-1)

```
require_once "vendor/autoload.php";

use ReallyWang\DynamoDB\DB;

// 整理配置
$config = [
    'default' => [
        'region' => '',
        'version' => '',
        'credentials' => [
            'key' => '',
            'secret' => ''
        ]
    ],
    'test' => [
        'region' => '',
        'version' => '',
        'credentials' => [
            'key' => '',
            'secret' => ''
        ]
    ]
];

// 获取连接对象
DB::config($config); // 默认为default
// DB::config($config, 'test'); // 使用test数据库配置

```

### 3. 新增数据

[](#3-新增数据-1)

```
// 向wrtest表中新增数据
$result = DB::table('wrtest')->insert(['id' => 1, 'detail' => '23123']);

```

### 4. 修改数据

[](#4-修改数据-1)

```
// 修改wrtest表中 id = 123 且detail 大于 2的行 detail 为 23123
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail' => ['>', 2]])->update(['detail' => '23123']);

```

### 5. 查询数据

[](#5-查询数据-1)

```
// 查询wrtest表中id = 123的数据（id 必须是主键，find方法必须与key方法同时使用）
$result = DB::table('wrtest')->key(['id' => '123'])->find();

// 查询wrtest表中id = 1 且 detail 大于 2 的数据中的detail属性，condition 中必须包括主键
$result = DB::table('wrtest')->condition(['id' => 1, 'detail' => ['>', 2]])->field(['detail'])->get();

// 查询wrtest表中detail 小于 0 或 detail 在 2 和 3 之间的数据
$result = DB::table('wrtest')->condition(['detail' => ['', 2]])->delete();

```

### 7. 获取数量

[](#7-获取数量-1)

```
// 获取wrtest表中 id = 123 且detail 大于 2的数据条数
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail' => ['>', 2]])->count();

```

### 8. 部分删除

[](#8-部分删除-1)

```
// 修改wrtest表中 id = 123 且detail 大于 2的行 detail 为 23123
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail' => ['>', 2]])->remove(['detail.author[0]']);

// 将wrtest表中 id = 123 且detail.author 中有3个元素 的行 detail.author中的第一个元素删掉
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail.author' => ['size', 3]])->remove(['detail.author[0]']);

// 将wrtest表中 id = 123 且detail.author 中元素数量大于等于3 的行 detail.author中的第一个元素删掉
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail.author' => ['size', '>=', 3]])->remove(['detail.author[0]']);

// 将wrtest表中 id = 123 且detail.author 中元素个数在3和10之间 的行 detail.author中的第一个元素删掉
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail.author' => ['size', 'between', 3, 10]])->remove(['detail.author[0]']);

```

### 9. 自增与自减

[](#9-自增与自减-1)

```
// wrtest表 符合 id 为123 的行 num属性会递增 1
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail' => '123'])->step('num');

// wrtest表 符合 id 为123 的行 num属性会递减 2
$result = DB::table('wrtest')->key(['id' => '123'])->condition(['detail' => '123'])->step('num', false, 2);

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

8

Last Release

2600d ago

Major Versions

v0.1 → 1.12019-02-28

1.5 → 2233.x-dev2019-04-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7ba9750028f0d87eef0f0a5bf878aa1ce3ba3b139a57593b6c3874677f89832?d=identicon)[ReallyWang](/maintainers/ReallyWang)

---

Top Contributors

[![RReallyWang](https://avatars.githubusercontent.com/u/47738608?v=4)](https://github.com/RReallyWang "RReallyWang (14 commits)")

### Embed Badge

![Health badge](/badges/reallywang-dynamo-db/health.svg)

```
[![Health](https://phpackages.com/badges/reallywang-dynamo-db/health.svg)](https://phpackages.com/packages/reallywang-dynamo-db)
```

###  Alternatives

[baopham/dynamodb

Eloquent syntax for DynamoDB

4975.7M6](/packages/baopham-dynamodb)[kitar/laravel-dynamodb

A DynamoDB based Eloquent model and Query builder for Laravel.

193675.3k1](/packages/kitar-laravel-dynamodb)[kettle/dynamodb-orm

A lightweight object-dynamodb mapper for PHP

49210.0k](/packages/kettle-dynamodb-orm)[swiftotter/driver

A database task-runner that helps you to turn production database into a staging/development database sandbox

6111.1k2](/packages/swiftotter-driver)[urbanindo/yii2-dynamodb

DynamoDB extensions for Yii2

1471.4k](/packages/urbanindo-yii2-dynamodb)[oryxcloud/laravel-dynamodb-session-driver

DynamoDB Session Driver for Laravel 5

1460.8k](/packages/oryxcloud-laravel-dynamodb-session-driver)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
