PHPackages                             alan/yii2-orm-dcache - 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. alan/yii2-orm-dcache

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

alan/yii2-orm-dcache
====================

yii2 framwork use dcache like yii2-orm

v1.0.1(5y ago)113PHPCI failing

Since Dec 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/wzzjjboy/yii2-orm-dcache)[ Packagist](https://packagist.org/packages/alan/yii2-orm-dcache)[ RSS](/packages/alan-yii2-orm-dcache/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Yii2 DCACHE ORM
===============

[](#yii2-dcache-orm)

1. 安装

    composer require alan/yii2-orm-dcache:dev-master
2. 配置

    - 添加dcache访问的http地址，本工具基于dcache的http访问接口编写

        建议添加到common\\config\\main-local.php文件添加

        ```
        //测试环境配置
        'dcache_data_center' => [
                'url' => 'http://xxx.xxx.xxx.xxx:xxxx',
                'key' => 'xxxxxxxx',
        ]
        ```
    - 添加dcache表对应的配置(此配置用于查询表结构，用于ORM操作)

        ```
        //测试和正式环境只要表结构一致就只需要添加一处即可
        'db_tars_order' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=host;port=port;dbname=db_name',
            'username' => 'username',
            'password' => 'password',
            'charset' => 'utf8',
            'enableSchemaCache' => true,
            'schemaCacheDuration' => 86400, // time in seconds
        ],
        'db_tars_relationship' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=host;port=prot;dbname=dbname',
            'username' => 'username',
            'password' => 'password',
            'charset' => 'utf8',
            'enableSchemaCache' => true,
            'schemaCacheDuration' => 86400, // time in seconds
        ],
        ```
3. 使用示例

    - 查询

    ```
    /** 查询一条 **/
    Invoice::find()->where(['order_sn' =>'xxxxx'])->asArray(false)->one()
    /** 查询多条 **/
    Invoice::find()->where(['order_sn' =>'xxxxx'])->asArray(false)->all()
    /** 取出数组 **/
    Invoice::find()->where(['order_sn' =>'xxxxx'])->asArray(false)->asArray()->all()
    ```

    - 更新

        ```
        public function actionUpdate($orderSn){
            /** @var Order $order */
            $order = Order::find()->where(['order_sn' => $orderSn])->asArray(false)->one();
            if (empty($order)){
                die("查询失败");
            }
            print_r($order->toArray());
            $order->b_user_id = "1234";
            $saveRsp = $order->save();
            if (!$saveRsp){
                print_r($order->getErrors());
            } else {
                $order = Order::find()->where(['order_sn' => $orderSn])->asArray(true)->one();
                print_r($order);
            }
        }
        ```
    - 删除

        ```
        public function actionDelete($orderSn){
            /** @var Order $order */
            $order = Order::find()->where(['order_sn' => $orderSn])->asArray(false)->one();
            if (empty($order)){
                die("查询失败");
            }
            $order->delete();
            $order = Order::find()->where(['order_sn' => $orderSn])->asArray(true)->one();
            print_r($order);
        }
        ```
4. 已知问题

    - dcache不支持limit语句，查询all时要注意取出数据的数量
    - orm不支里面使用带查询的验证器，比如union验证器。建议放在外层自验证验证唯一性

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~214 days

Total

2

Last Release

2119d ago

### Community

Maintainers

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

---

Top Contributors

[![lzcmaro](https://avatars.githubusercontent.com/u/15357931?v=4)](https://github.com/lzcmaro "lzcmaro (2 commits)")[![wzzjjboy](https://avatars.githubusercontent.com/u/13265064?v=4)](https://github.com/wzzjjboy "wzzjjboy (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alan-yii2-orm-dcache/health.svg)

```
[![Health](https://phpackages.com/badges/alan-yii2-orm-dcache/health.svg)](https://phpackages.com/packages/alan-yii2-orm-dcache)
```

###  Alternatives

[yii2tech/illuminate

Yii2 to Laravel Migration Package

11315.1k](/packages/yii2tech-illuminate)[mootensai/yii2-relation-trait

Yii 2 Models load with relation, &amp; transaction save with relation

47220.3k9](/packages/mootensai-yii2-relation-trait)[nhkey/yii2-activerecord-history

Storage history of changes to ActiveRecord

46143.4k1](/packages/nhkey-yii2-activerecord-history)[dmstr/yii2-db

Database extensions

19618.8k6](/packages/dmstr-yii2-db)[urbanindo/yii2-dynamodb

DynamoDB extensions for Yii2

1471.4k](/packages/urbanindo-yii2-dynamodb)[spanjeta/yii2-backup

Database Backup and Restore functionality

285.0k1](/packages/spanjeta-yii2-backup)

PHPackages © 2026

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