PHPackages                             topsyx6/syx6-orm - 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. topsyx6/syx6-orm

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

topsyx6/syx6-orm
================

syx6 orm

V2.0.26(6y ago)011Apache-2.0PHPPHP &gt;=7.1.0

Since Sep 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/qwe2824253/syx6-orm)[ Packagist](https://packagist.org/packages/topsyx6/syx6-orm)[ RSS](/packages/topsyx6-syx6-orm/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

syx6-orm
========

[](#syx6-orm)

syx6PHP6内置ORM，基于PHP7.1+ 的ORM实现，主要特性：

- 支持Mysql、Pgsql、Sqlite、SqlServer、Oracle和Mongodb
- 支持Db类和查询构造器
- 支持事务
- 支持模型和关联
- 事件支持依赖注入
- 支持使用Db门面对象
- 支持查询缓存

安装
--

[](#安装)

```
composer require topsyx6/syx6-orm

```

使用
--

[](#使用)

Db类：

```
use syx6\facade\Db;
// 数据库配置信息设置（全局有效）
Db::setConfig([
    // 默认数据连接标识
    'default'     => 'mysql',
    // 数据库连接信息
    'connections' => [
        'mysql' => [
            // 数据库类型
            'type'     => 'mysql',
            // 主机地址
            'hostname' => '127.0.0.1',
            // 用户名
            'username' => 'root',
            // 数据库名
            'database' => 'demo',
            // 数据库编码默认采用utf8
            'charset'  => 'utf8',
            // 数据库表前缀
            'prefix'   => 'syx6_',
        ],
        'mongo' => [
            // 数据库类型
            'type'          => 'mongo',
            // 服务器地址
            'hostname'      => '127.0.0.1',
            // 数据库名
            'database'      => 'demo',
            // 用户名
            'username'      => '',
            // 密码
            'password'      => '',
            // 主键转换为Id
            'pk_convert_id' => true,
            // 端口
            'hostport'      => '27017',
        ],
    ],
]);
// 进行CURD操作
Db::table('user')
	->data(['name'=>'syx6php','email'=>'syx6php@qq.com'])
	->insert();
Db::table('user')->find();
Db::table('user')
	->where('id','>',10)
	->order('id','desc')
	->limit(10)
	->select();
Db::table('user')
	->where('id',10)
	->update(['name'=>'test']);
Db::table('user')
	->where('id',10)
	->delete();
// 获取数据库SQL日志记录
Db::getSqlLog();
```

其它操作参考syx6的完全开发手册[数据库](https://www.kancloud.cn/manual/syx6php6_0/1037530)章节

模型：

```
namespace app\index\model;

use syx6\Model;

class User extends Model
{
}
```

代码调用：

```
use app\index\model\User;

$user = User::find(1);
$user->name = 'syx6php';
$user->save();
```

Db类和模型对比使用
----------

[](#db类和模型对比使用)

#### ✅ 创建Create

[](#white_check_mark---创建create)

- Db用法

    ```
    Db::table('user')
        ->insert([
            'name'  => 'syx6php',
            'email' => 'syx6php@qq.com',
        ]);
    ```
- 模型用法

    ```
    $user        = new User;
    $user->name  = 'syx6php';
    $user->email = 'syx6php@qq.com';
    $user->save();
    ```
- 或者批量设置

    ```
    $user = new User;
    $user->save([
        'name'  => 'syx6php',
        'email' => 'syx6php@qq.com',
    ]);
    ```

#### ✅ 读取Read

[](#white_check_mark--读取read)

- Db用法

    ```
    $user = Db::table('user')
        ->where('id', 1)
        ->find();
    //  或者
    $user = Db::table('user')
        ->find(1);
    echo $user['id'];
    echo $user['name'];
    ```
- 模型用法

    ```
    $user = User::find(1);
    echo $user->id;
    echo $user->name;
    ```
- 模型实现读取多个记录

    ```
    // 查询用户数据集
    $users = User::where('id', '>', 1)
        ->limit(5)
        ->select();

    // 遍历读取用户数据
    foreach ($users as $user) {
        echo $user->id;
        echo $user->name;
    }
    ```

#### ✅ 更新Update

[](#white_check_mark--更新update)

- Db用法

    ```
    Db::table('user')
        ->where('id', 1)
        ->update([
            'name'  => 'topsyx6',
            'email' => 'topsyx6@qq.com',
        ]);
    ```
- 模型用法

    ```
    $user        = User::find(1);
    $user->name  = 'topsyx6';
    $user->email = 'topsyx6@qq.com';
    $user->save();
    ```
- 或者使用

    ```
    $user = User::find(1);
    $user->save([
        'name'  => 'topsyx6',
        'email' => 'topsyx6@qq.com',
    ]);
    ```
- 静态调用

    ```
    User::update([
        'name'  => 'topsyx6',
        'email' => 'topsyx6@qq.com',
    ], ['id' => 1]);
    ```

#### ✅ 删除Delete

[](#white_check_mark--删除delete)

- Db用法

    ```
    Db::table('user')->delete(1);
    ```
- 模型用法

    ```
    $user = User::find(1);
    $user->delete();
    ```
- 或者静态实现

    ```
    User::destroy(1);
    ```
- destroy方法支持删除指定主键或者查询条件的数据

    ```
    // 根据主键删除多个数据
    User::destroy([1, 2, 3]);
    // 指定条件删除数据
    User::destroy([
        'status' => 0,
    ]);
    // 使用闭包条件
    User::destroy(function ($query) {
        $query->where('id', '>', 0)
            ->where('status', 0);
    });
    ```

更多模型用法可以参考6.0完全开发手册的[模型](https://www.kancloud.cn/manual/syx6php6_0/1037579)章节

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

3

Last Release

2468d ago

Major Versions

v1.0 → V2.0.252019-09-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12124617?v=4)[sunyixin](/maintainers/qwe2824253)[@qwe2824253](https://github.com/qwe2824253)

---

Tags

databaseorm

### Embed Badge

![Health badge](/badges/topsyx6-syx6-orm/health.svg)

```
[![Health](https://phpackages.com/badges/topsyx6-syx6-orm/health.svg)](https://phpackages.com/packages/topsyx6-syx6-orm)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[directorytree/ldaprecord

A fully-featured LDAP ORM.

5793.3M15](/packages/directorytree-ldaprecord)[cycle/database

DBAL, schema introspection, migration and pagination

65746.2k48](/packages/cycle-database)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

816.0k](/packages/tommyknocker-pdo-database-class)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

249.4k](/packages/perplorm-perpl)

PHPackages © 2026

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