Skip to content

Commit 2b37fe3

Browse files
committed
完善 Database join, on, orderBy
1 parent d9a9b68 commit 2b37fe3

File tree

3 files changed

+168
-87
lines changed

3 files changed

+168
-87
lines changed

.idea/workspace.xml

Lines changed: 74 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

App/Controller/apiController.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ class apiController {
1010
*/
1111
public function test($id){
1212

13-
// 测试数据库层封装
14-
$result = Database::table('demo')
15-
->setModel(Demo::class)
16-
->select('title')
17-
->where(["author" => "Rytia"])
18-
->orWhereRaw('content LIKE "%测试%"')
19-
->paginate(5);
20-
21-
print_r($result);
22-
2313
}
2414

2515
// ORM 查询类方法演示
@@ -94,7 +84,6 @@ public function paginate($pageNum){
9484
}
9585

9686
public function databaseWhere(){
97-
9887
// 数据库层封装演示1
9988
$result = Database::table('demo')
10089
->setModel(Demo::class)
@@ -107,4 +96,15 @@ public function databaseWhere(){
10796

10897
}
10998

99+
public function databaseOn(){
100+
// 数据库层封装演示2
101+
$result = Database::table('wiki')
102+
->select('DISTINCT zhong.name,wiki.coordinate')
103+
->join('zhong')
104+
->on('wiki.zhong=zhong.id')
105+
->orderBy("coordinate", "DESC")
106+
->fetchAll();
107+
print_r($result);
108+
109+
}
110110
}

0 commit comments

Comments
 (0)