PHPackages                             mix/sharding-query - 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. mix/sharding-query

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

mix/sharding-query
==================

数据库分表分页查询库 (不依赖框架)

v1.0.1(7y ago)16233Apache-2.0PHPPHP &gt;=5.4.0

Since Feb 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mix-basic/Sharding-Query)[ Packagist](https://packagist.org/packages/mix/sharding-query)[ Docs](https://github.com/mix-basic/Sharding-Query)[ RSS](/packages/mix-sharding-query/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

ShardingQuery
-------------

[](#shardingquery)

分表数据查询类

安装
--

[](#安装)

使用 `composer` 安装：

```
composer require mix/sharding-query

```

使用方法
----

[](#使用方法)

ThinkPHP 5 的范例，支持任何框架，只需修改 `query` 参数的闭包代码。

```
$query = new \ShardingQuery\Query([
    'query'    => function ($sql) {
        return \think\Db::query($sql);
    },
    'table'    => [
        'order',
        'order_201805',
        'order_201804',
    ],
    'field'    => '{table}.*, u.name',
    'leftJoin' => [
        'user AS u ON u.member_id = {table}.member_id',
    ],
    'where'    => '{table}.member_id = 10001 AND status = 1',
    'order'    => '{table}.add_time DESC',
    'offset'   => 0,
    'limit'    => 10,
]);
// 查询结果
$result        = $query->select();
// 总行数，用于分页
$count         = $query->count();
// 追踪数据，用于调试
$trace         = $query->trace();
```

全部参数：

- `query`：执行 sql 返回结果的闭包，接收一个 $sql 参数，返回查询结果。
- `table`：要查询的多个同构表的清单，数组类型。
- `field`：select 选择的列名，字符串类型。
- `innerJoin`：join信息，数组类型。
- `leftJoin`：join信息，数组类型。
- `where`：查询条件，字符串类型。
- `order`：排序，字符串类型。
- `offset`：偏移数，整数类型。
- `limit`：限制数，整数类型。

License
-------

[](#license)

Apache License Version 2.0,

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

2645d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16074765?v=4)[LIU JIAN](/maintainers/onanying)[@onanying](https://github.com/onanying)

---

Top Contributors

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

---

Tags

querysharding

### Embed Badge

![Health badge](/badges/mix-sharding-query/health.svg)

```
[![Health](https://phpackages.com/badges/mix-sharding-query/health.svg)](https://phpackages.com/packages/mix-sharding-query)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.0M14](/packages/rennokki-laravel-eloquent-query-cache)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925511.7k13](/packages/envms-fluentpdo)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[bvanhoekelen/performance

PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.

521774.3k4](/packages/bvanhoekelen-performance)

PHPackages © 2026

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