File tree Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 7
7
ThinkPHP 5 的范例,支持任何框架,只需修改 ` query ` 参数的闭包代码。
8
8
9
9
``` php
10
- $shardingQuery = new ShardingQuery([
10
+ $query = new \ ShardingQuery\Query ([
11
11
'query' => function ($sql) {
12
12
return \think\Db::query($sql);
13
13
},
@@ -26,11 +26,11 @@ $shardingQuery = new ShardingQuery([
26
26
'limit' => 10,
27
27
]);
28
28
// 查询结果
29
- $result = $shardingQuery ->select();
29
+ $result = $query ->select();
30
30
// 总行数,用于分页
31
- $count = $shardingQuery ->count();
31
+ $count = $query ->count();
32
32
// 追踪数据,用于调试
33
- $trace = $shardingQuery ->trace();
33
+ $trace = $query ->trace();
34
34
```
35
35
36
36
全部参数:
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " mix/sharding-query" ,
3
+ "description" : " 数据库分表分页查询库 (不依赖框架)" ,
4
+ "type" : " library" ,
5
+ "keywords" : [
6
+ " sharding" ,
7
+ " query"
8
+ ],
9
+ "homepage" : " https://github.com/mix-basic/Sharding-Query" ,
10
+ "license" : " Apache-2.0" ,
11
+ "authors" : [
12
+ {
13
+ "name" : " Jian Liu" ,
14
+
15
+ }
16
+ ],
17
+ "require" : {
18
+ "php" : " >=5.4.0"
19
+ },
20
+ "autoload" : {
21
+ "psr-4" : {
22
+ "ShardingQuery\\ " : " src/"
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ namespace ShardingQuery ;
4
+
3
5
/**
4
6
* 分表数据查询类
7
+ * @package ShardingQuery
5
8
* @author LIUJIAN <[email protected] >
6
9
*/
7
- class ShardingQuery
10
+ class Query
8
11
{
9
12
10
13
/**
You can’t perform that action at this time.
0 commit comments