File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 9
9
适用于不使用ThinkPHP框架的开发者。
10
10
11
11
安装
12
- ~~~
12
+
13
+ ``` php
13
14
composer require topthink/think-orm
14
- ~~~
15
+ ```
15
16
16
17
Db类用法:
17
- ~~~
18
+
19
+ ``` php
18
20
use think\Db;
19
21
// 数据库配置信息设置(全局有效)
20
22
Db::setConfig(['数据库配置参数(数组)']);
21
23
// 进行CURD操作
22
24
Db::table('user')->find();
23
- ~~~
25
+ ```
24
26
25
27
Db类增加的(静态)方法包括:
26
28
- ` setConfig ` 设置全局配置信息
@@ -32,23 +34,24 @@ Db类增加的(静态)方法包括:
32
34
其它操作参考TP5.1的完全开发手册[ 数据库] ( https://www.kancloud.cn/manual/thinkphp5_1/353998 ) 章节
33
35
34
36
定义模型:
35
- ~~~
37
+
38
+ ``` php
36
39
<?php
37
40
namespace app\index\model;
38
41
use think\Model;
39
42
class User extends Model
40
43
{
41
44
}
42
- ~~~
45
+ ```
43
46
44
47
代码调用:
45
48
46
- ~~~
49
+ ``` php
47
50
use app\index\model\User;
48
51
49
52
$user = User::get(1);
50
53
$user->name = 'thinkphp';
51
54
$user->save();
52
- ~~~
55
+ ```
53
56
54
- 更多模型用法可以参考5.1完全开发手册的[ 模型] ( https://www.kancloud.cn/manual/thinkphp5_1/354041 ) 章节
57
+ 更多模型用法可以参考5.1完全开发手册的[ 模型] ( https://www.kancloud.cn/manual/thinkphp5_1/354041 ) 章节
You can’t perform that action at this time.
0 commit comments