PHPackages                             luffyzhao/luffy-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. luffyzhao/luffy-db

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

luffyzhao/luffy-db
==================

1.1.0(8y ago)027PHPPHP &gt;=7.0.0

Since Aug 21Pushed 8y ago1 watchersCompare

[ Source](https://github.com/luffyzhao/db)[ Packagist](https://packagist.org/packages/luffyzhao/luffy-db)[ RSS](/packages/luffyzhao-luffy-db/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (7)Used By (0)

luffyzhao 数据库操作类
----------------

[](#luffyzhao-数据库操作类)

`luffyzhao-db`是一个数据库操作类，支持各种数据库的增、删、改、查、执行存储过程等。目前还只支持`mysql`。欢迎star、fork、试用

- 支持mysql
- 支持分布式布局
- 支持读写分离
- 支持日志输出

#### 安装

[](#安装)

```
   composer require luffyzhao/luffy-db

```

```
或者

```

```
    git@github.com:lovezhao311/luffy-db.git

```

#### 环境要求

[](#环境要求)

- php 7.0 +

#### 使用方法

[](#使用方法)

```
    require __DIR__ . '/../vendor/autoload.php';
    use luffyzhao\db\Db;

    /**
     * 测试读写分离和分布式
     */
    $database = [
        // 数据库类型
        'type' => 'mysql',
        // 服务器地址
        'hostname' => '127.0.0.1,127.0.0.1',
        // 数据库名
        'database' => 'test,test1',
        // 用户名
        'username' => 'root',
        // 密码
        'password' => '123456',
        // 端口
        'hostport' => '3306',
        // 分布式
        'deploy' => 1,
        // 读写分享
        'rw_separate' => true,
        // 调试
        'debug' => function ($messgaes) {
            echo "[" . date('Y-m-d H:i:s') . "]" . $messgaes . "\n";
        },
    ];
    $db = new Db($database);
    //插入数据
    $res = $db->table('test_db')->data('name', '战非')->data('phone', '15215214578')->insert();

    // 没有数据
    $res = $db->table('test_db')->where('phone', '=', '15215214578')->findAll();
    // 有数据 (事务开始之后拿主库里的数据)
    $db->startTrans();
    $res = $db->table('test_db')->findAll();
    $db->commit();
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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 ~1 days

Total

6

Last Release

3227d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2227a3fc2aec1575739253293ba2d1044ec99e101826a8e0bfeb120ce19843d2?d=identicon)[luffyzhao](/maintainers/luffyzhao)

---

Top Contributors

[![luffyzhao](https://avatars.githubusercontent.com/u/4166371?v=4)](https://github.com/luffyzhao "luffyzhao (21 commits)")

---

Tags

dbmysqlphp

### Embed Badge

![Health badge](/badges/luffyzhao-luffy-db/health.svg)

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

PHPackages © 2026

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