PHPackages                             thefunpower/think-mongodb - 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. thefunpower/think-mongodb

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

thefunpower/think-mongodb
=========================

mongodb

v2.0.6(1y ago)046Apache-2.0PHP

Since Mar 14Pushed 1y agoCompare

[ Source](https://github.com/thefunpower/think-mongodb)[ Packagist](https://packagist.org/packages/thefunpower/think-mongodb)[ RSS](/packages/thefunpower-think-mongodb/feed)WikiDiscussions main Synced 1mo ago

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

Mongo
=====

[](#mongo)

安装
--

[](#安装)

```
composer require thefunpower/think-mongodb

```

或在`composer.json`添加

```
"thefunpower/think-mongodb":"^2"

```

### 激活数据库连接

[](#激活数据库连接)

```
db_active($value = 'mongo')

```

### 添加记录

[](#添加记录)

```
db_insert($table, $data, $use_action = true)

```

`action`

```
do_action("db.insert.before.".$table, $data);

```

```
do_action("db.insert.".$table, $ref);

```

$ref 为

```
['data' => $data,'id' => $id];

```

### 更新记录

[](#更新记录)

```
db_update($table, $update_data, $where, $use_action = true)

```

`action`

```
$ref = ['data' => $update_data,'where' => $where];
do_action("db.update.before.".$table, $ref);

do_action("db.update.".$table, $ref);

```

### 删除记录

[](#删除记录)

```
db_del($table, $where)

```

`action`

```
$ref = ['where' => $where];
do_action("db.del.".$table, $ref);

```

### 字段允许

[](#字段允许)

- 设置允许字段

```
db_allow_set($table, $data)

```

- 获取允许数据

```
$data = db_allow($table, $data);

```

### 设置或取ID

[](#设置或取id)

```
get_id_by_auto_insert($table, $data = [], $where = [], $has_time_and_update = false)

```

### 设置字段类型

[](#设置字段类型)

```
db_set_field_type('table',[
  'num'=>'int',
  'price'=>'float',
]);

```

### 分页

[](#分页)

```
db_pager($table, $field = []);

```

### 事务

[](#事务)

```
db_action(function(){

});

```

### group by 查寻

[](#group-by-查寻)

```
$a = date("Y-m-d 00:00:00",$yesterday);
$b = date("Y-m-d 23:59:59",$yesterday);
$where['created_at[]'] = [$a,$b];
$where["GROUP"] = ['type','nid'];
$all = db_get("hardware",["SUM(price)"=>'amount',],$where);
$d['list'] = db_get("hardware",[
     "SUM(t)"=>'t',
     'min(t)'=>'t1',
],[
  'drive[!]'=>['gx'],
  'GROUP'=> [
    'tag',
    'drive',
  ],
  'HAVING'=>[
      't[>]'=>0
  ],
  'ORDER'=>[
    't'=>'asc'
  ]
]);

```

LICENSE
-------

[](#license)

[Apache License 2.0](LICENSE)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Total

5

Last Release

703d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

php

### Embed Badge

![Health badge](/badges/thefunpower-think-mongodb/health.svg)

```
[![Health](https://phpackages.com/badges/thefunpower-think-mongodb/health.svg)](https://phpackages.com/packages/thefunpower-think-mongodb)
```

###  Alternatives

[eftec/pdoone

Minimaist procedural PDO wrapper library

1105.9k9](/packages/eftec-pdoone)[simple-swoole/db

A db component for Simps.

216.3k3](/packages/simple-swoole-db)

PHPackages © 2026

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