Skip to content

Commit 85a527e

Browse files
committed
Merge branch 'master' of https://github.com/top-think/think-orm
2 parents 8bf919a + cecd27f commit 85a527e

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
适用于不使用ThinkPHP框架的开发者。
1010

1111
安装
12-
~~~
12+
13+
```php
1314
composer require topthink/think-orm
14-
~~~
15+
```
1516

1617
Db类用法:
17-
~~~
18+
19+
```php
1820
use think\Db;
1921
// 数据库配置信息设置(全局有效)
2022
Db::setConfig(['数据库配置参数(数组)']);
2123
// 进行CURD操作
2224
Db::table('user')->find();
23-
~~~
25+
```
2426

2527
Db类增加的(静态)方法包括:
2628
- `setConfig` 设置全局配置信息
@@ -32,23 +34,24 @@ Db类增加的(静态)方法包括:
3234
其它操作参考TP5.1的完全开发手册[数据库](https://www.kancloud.cn/manual/thinkphp5_1/353998)章节
3335

3436
定义模型:
35-
~~~
37+
38+
```php
3639
<?php
3740
namespace app\index\model;
3841
use think\Model;
3942
class User extends Model
4043
{
4144
}
42-
~~~
45+
```
4346

4447
代码调用:
4548

46-
~~~
49+
```php
4750
use app\index\model\User;
4851

4952
$user = User::get(1);
5053
$user->name = 'thinkphp';
5154
$user->save();
52-
~~~
55+
```
5356

54-
更多模型用法可以参考5.1完全开发手册的[模型](https://www.kancloud.cn/manual/thinkphp5_1/354041)章节
57+
更多模型用法可以参考5.1完全开发手册的[模型](https://www.kancloud.cn/manual/thinkphp5_1/354041)章节

src/Paginator.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function url($page)
138138
*/
139139
public static function getCurrentPage($varPage = 'page', $default = 1)
140140
{
141-
$page = Container::get('request')->param($varPage);
141+
$page = isset($_REQUEST[$varPage]) ? $_REQUEST[$varPage] : 1;
142142

143143
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
144144
return $page;
@@ -153,7 +153,17 @@ public static function getCurrentPage($varPage = 'page', $default = 1)
153153
*/
154154
public static function getCurrentPath()
155155
{
156-
return Container::get('request')->baseUrl();
156+
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
157+
$url = $_SERVER['HTTP_X_REWRITE_URL'];
158+
} elseif (isset($_SERVER['REQUEST_URI'])) {
159+
$url = $_SERVER['REQUEST_URI'];
160+
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
161+
$url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
162+
} else {
163+
$url = '';
164+
}
165+
166+
return strpos($url, '?') ? strstr($url, '?', true) : $url;
157167
}
158168

159169
public function total()

src/db/exception/DataNotFoundException.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace think\db\exception;
1313

14-
use think\exception\DbException;
15-
1614
class DataNotFoundException extends DbException
1715
{
1816
protected $table;

src/model/concern/ModelEvent.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace think\model\concern;
1313

14-
use think\Container;
15-
1614
/**
1715
* 模型事件处理
1816
*/
@@ -52,7 +50,7 @@ protected function trigger($event)
5250

5351
if (isset(self::$event[$class][$event])) {
5452
foreach (self::$event[$class][$event] as $callback) {
55-
$result = Container::getInstance()->invoke($callback, [$this]);
53+
$result = call_user_func_array($callback, [$this]);
5654

5755
if (false === $result) {
5856
return false;

0 commit comments

Comments
 (0)