框架更新
parent
17438dbd90
commit
a83f52d8f3
|
|
@ -449,16 +449,16 @@
|
|||
},
|
||||
{
|
||||
"name": "topthink/framework",
|
||||
"version": "v6.0.8",
|
||||
"version": "v6.0.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/top-think/framework.git",
|
||||
"reference": "4789343672aef06d571d556da369c0e156609bce"
|
||||
"reference": "0b5fb453f0e533de3af3a1ab6a202510b61be617"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/top-think/framework/zipball/4789343672aef06d571d556da369c0e156609bce",
|
||||
"reference": "4789343672aef06d571d556da369c0e156609bce",
|
||||
"url": "https://api.github.com/repos/top-think/framework/zipball/0b5fb453f0e533de3af3a1ab6a202510b61be617",
|
||||
"reference": "0b5fb453f0e533de3af3a1ab6a202510b61be617",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
|
|
@ -470,9 +470,9 @@
|
|||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"league/flysystem": "^1.0",
|
||||
"league/flysystem": "^1.1.4",
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"php": ">=7.1.0",
|
||||
"php": ">=7.2.5",
|
||||
"psr/container": "~1.0",
|
||||
"psr/log": "~1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
|
|
@ -514,9 +514,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/top-think/framework/issues",
|
||||
"source": "https://github.com/top-think/framework/tree/v6.0.8"
|
||||
"source": "https://github.com/top-think/framework/tree/v6.0.9"
|
||||
},
|
||||
"time": "2021-04-27T00:41:08+00:00"
|
||||
"time": "2021-07-22T03:24:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "topthink/think-helper",
|
||||
|
|
@ -623,16 +623,16 @@
|
|||
},
|
||||
{
|
||||
"name": "topthink/think-orm",
|
||||
"version": "v2.0.41",
|
||||
"version": "v2.0.44",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/top-think/think-orm.git",
|
||||
"reference": "64bbfdde01f4fd6939c2f695fceb08e6d764ac6b"
|
||||
"reference": "5d3d5c1ebf8bfccf34bacd90edb42989b16ea409"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/top-think/think-orm/zipball/64bbfdde01f4fd6939c2f695fceb08e6d764ac6b",
|
||||
"reference": "64bbfdde01f4fd6939c2f695fceb08e6d764ac6b",
|
||||
"url": "https://api.github.com/repos/top-think/think-orm/zipball/5d3d5c1ebf8bfccf34bacd90edb42989b16ea409",
|
||||
"reference": "5d3d5c1ebf8bfccf34bacd90edb42989b16ea409",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
|
|
@ -678,9 +678,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/top-think/think-orm/issues",
|
||||
"source": "https://github.com/top-think/think-orm/tree/v2.0.41"
|
||||
"source": "https://github.com/top-think/think-orm/tree/v2.0.44"
|
||||
},
|
||||
"time": "2021-07-14T07:51:15+00:00"
|
||||
"time": "2021-07-21T02:22:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "topthink/think-template",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// +----------------------------------------------------------------------
|
||||
|
||||
// 检测PHP环境
|
||||
if(version_compare(PHP_VERSION,'7.1.0','<')) die('PHP版本最低 7.1.0');
|
||||
if(version_compare(PHP_VERSION,'7.2.0','<')) die('PHP版本最低 7.2.0');
|
||||
|
||||
// 系统版本
|
||||
define('APPLICATION_VERSION', 'v2.2.0');
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ return array(
|
|||
'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'),
|
||||
'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
|
||||
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
|
||||
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
|
||||
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/framework/src/think'),
|
||||
'app\\' => array($baseDir . '/app'),
|
||||
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
|
||||
'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'),
|
||||
|
|
|
|||
|
|
@ -64,10 +64,10 @@ class ComposerStaticInit1ed187777399b73a018d9a6af63a57d1
|
|||
),
|
||||
'think\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/topthink/framework/src/think',
|
||||
1 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
||||
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
||||
1 => __DIR__ . '/..' . '/topthink/think-template/src',
|
||||
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
|
||||
3 => __DIR__ . '/..' . '/topthink/think-template/src',
|
||||
3 => __DIR__ . '/..' . '/topthink/framework/src/think',
|
||||
),
|
||||
'app\\' =>
|
||||
array (
|
||||
|
|
|
|||
|
|
@ -762,25 +762,31 @@
|
|||
},
|
||||
{
|
||||
"name": "topthink/framework",
|
||||
"version": "v6.0.8",
|
||||
"version_normalized": "6.0.8.0",
|
||||
"version": "v6.0.9",
|
||||
"version_normalized": "6.0.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/top-think/framework.git",
|
||||
"reference": "4789343672aef06d571d556da369c0e156609bce"
|
||||
"reference": "0b5fb453f0e533de3af3a1ab6a202510b61be617"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/top-think/framework/zipball/4789343672aef06d571d556da369c0e156609bce",
|
||||
"reference": "4789343672aef06d571d556da369c0e156609bce",
|
||||
"shasum": ""
|
||||
"url": "https://api.github.com/repos/top-think/framework/zipball/0b5fb453f0e533de3af3a1ab6a202510b61be617",
|
||||
"reference": "0b5fb453f0e533de3af3a1ab6a202510b61be617",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"league/flysystem": "^1.0",
|
||||
"league/flysystem": "^1.1.4",
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"php": ">=7.1.0",
|
||||
"php": ">=7.2.5",
|
||||
"psr/container": "~1.0",
|
||||
"psr/log": "~1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
|
|
@ -792,7 +798,7 @@
|
|||
"mockery/mockery": "^1.2",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"time": "2021-04-27T00:41:08+00:00",
|
||||
"time": "2021-07-22T03:24:49+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
|
@ -824,7 +830,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/top-think/framework/issues",
|
||||
"source": "https://github.com/top-think/framework/tree/v6.0.8"
|
||||
"source": "https://github.com/top-think/framework/tree/v6.0.9"
|
||||
},
|
||||
"install-path": "../topthink/framework"
|
||||
},
|
||||
|
|
@ -927,17 +933,17 @@
|
|||
},
|
||||
{
|
||||
"name": "topthink/think-orm",
|
||||
"version": "v2.0.41",
|
||||
"version_normalized": "2.0.41.0",
|
||||
"version": "v2.0.44",
|
||||
"version_normalized": "2.0.44.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/top-think/think-orm.git",
|
||||
"reference": "64bbfdde01f4fd6939c2f695fceb08e6d764ac6b"
|
||||
"reference": "5d3d5c1ebf8bfccf34bacd90edb42989b16ea409"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/top-think/think-orm/zipball/64bbfdde01f4fd6939c2f695fceb08e6d764ac6b",
|
||||
"reference": "64bbfdde01f4fd6939c2f695fceb08e6d764ac6b",
|
||||
"url": "https://api.github.com/repos/top-think/think-orm/zipball/5d3d5c1ebf8bfccf34bacd90edb42989b16ea409",
|
||||
"reference": "5d3d5c1ebf8bfccf34bacd90edb42989b16ea409",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
|
|
@ -957,7 +963,7 @@
|
|||
"require-dev": {
|
||||
"phpunit/phpunit": "^7|^8|^9.5"
|
||||
},
|
||||
"time": "2021-07-14T07:51:15+00:00",
|
||||
"time": "2021-07-21T02:22:31+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
|
@ -985,7 +991,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/top-think/think-orm/issues",
|
||||
"source": "https://github.com/top-think/think-orm/tree/v2.0.41"
|
||||
"source": "https://github.com/top-think/think-orm/tree/v2.0.44"
|
||||
},
|
||||
"install-path": "../topthink/think-orm"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '6c215fcba72e60dc4017bd65b0bc08b8b67c94d2',
|
||||
'reference' => '17438dbd90d9945b175a1e428da20474e46aff80',
|
||||
'name' => 'shopxo/shopxo',
|
||||
'dev' => true,
|
||||
),
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '6c215fcba72e60dc4017bd65b0bc08b8b67c94d2',
|
||||
'reference' => '17438dbd90d9945b175a1e428da20474e46aff80',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/polyfill-mbstring' => array(
|
||||
|
|
@ -119,12 +119,12 @@
|
|||
'dev_requirement' => true,
|
||||
),
|
||||
'topthink/framework' => array(
|
||||
'pretty_version' => 'v6.0.8',
|
||||
'version' => '6.0.8.0',
|
||||
'pretty_version' => 'v6.0.9',
|
||||
'version' => '6.0.9.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../topthink/framework',
|
||||
'aliases' => array(),
|
||||
'reference' => '4789343672aef06d571d556da369c0e156609bce',
|
||||
'reference' => '0b5fb453f0e533de3af3a1ab6a202510b61be617',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-helper' => array(
|
||||
|
|
@ -146,12 +146,12 @@
|
|||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-orm' => array(
|
||||
'pretty_version' => 'v2.0.41',
|
||||
'version' => '2.0.41.0',
|
||||
'pretty_version' => 'v2.0.44',
|
||||
'version' => '2.0.44.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../topthink/think-orm',
|
||||
'aliases' => array(),
|
||||
'reference' => '64bbfdde01f4fd6939c2f695fceb08e6d764ac6b',
|
||||
'reference' => '5d3d5c1ebf8bfccf34bacd90edb42989b16ea409',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-template' => array(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is automatically generated at:2021-07-19 11:36:48
|
||||
// This file is automatically generated at:2021-07-22 11:43:19
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\app\\Service',
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ language: php
|
|||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
- php: 8.0
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.0",
|
||||
"php": ">=7.2.5",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"league/flysystem": "^1.0",
|
||||
"league/flysystem": "^1.1.4",
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"psr/log": "~1.0",
|
||||
"psr/container": "~1.0",
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use think\initializer\RegisterService;
|
|||
*/
|
||||
class App extends Container
|
||||
{
|
||||
const VERSION = '6.0.8';
|
||||
const VERSION = '6.0.9';
|
||||
|
||||
/**
|
||||
* 应用调试模式
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class Event
|
|||
'HttpEnd' => event\HttpEnd::class,
|
||||
'RouteLoaded' => event\RouteLoaded::class,
|
||||
'LogWrite' => event\LogWrite::class,
|
||||
'LogRecord' => event\LogRecord::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -215,6 +216,14 @@ class Event
|
|||
|
||||
$result = [];
|
||||
$listeners = $this->listener[$event] ?? [];
|
||||
|
||||
if (strpos($event, '.')) {
|
||||
[$prefix, $event] = explode('.', $event, 2);
|
||||
if (isset($this->listener[$prefix . '.*'])) {
|
||||
$listeners = array_merge($listeners, $this->listener[$prefix . '.*']);
|
||||
}
|
||||
}
|
||||
|
||||
$listeners = array_unique($listeners, SORT_REGULAR);
|
||||
|
||||
foreach ($listeners as $key => $listener) {
|
||||
|
|
|
|||
|
|
@ -408,7 +408,8 @@ class Request implements ArrayAccess
|
|||
$rootDomain = $this->rootDomain();
|
||||
|
||||
if ($rootDomain) {
|
||||
$this->subDomain = rtrim(stristr($this->host(), $rootDomain, true), '.');
|
||||
$sub = stristr($this->host(), $rootDomain, true);
|
||||
$this->subDomain = $sub ? rtrim($sub, '.') : '';
|
||||
} else {
|
||||
$this->subDomain = '';
|
||||
}
|
||||
|
|
@ -878,10 +879,12 @@ class Request implements ArrayAccess
|
|||
*/
|
||||
public function all($name = '', $filter = '')
|
||||
{
|
||||
$data = array_merge($this->param(), $this->file());
|
||||
$data = array_merge($this->param(), $this->file() ?: []);
|
||||
|
||||
if (is_array($name)) {
|
||||
$data = $this->only($name, $data, $filter);
|
||||
} elseif ($name) {
|
||||
$data = $data[$name] ?? null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
@ -1147,7 +1150,6 @@ class Request implements ArrayAccess
|
|||
{
|
||||
$files = $this->file;
|
||||
if (!empty($files)) {
|
||||
|
||||
if (strpos($name, '.')) {
|
||||
[$name, $sub] = explode('.', $name);
|
||||
}
|
||||
|
|
@ -1307,12 +1309,12 @@ class Request implements ArrayAccess
|
|||
|
||||
/**
|
||||
* 强制类型转换
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param mixed $data
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
private function typeCast(&$data, string $type)
|
||||
protected function typeCast(&$data, string $type)
|
||||
{
|
||||
switch (strtolower($type)) {
|
||||
// 数组
|
||||
|
|
@ -1344,7 +1346,7 @@ class Request implements ArrayAccess
|
|||
|
||||
/**
|
||||
* 获取数据
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $data 数据源
|
||||
* @param string $name 字段名
|
||||
* @param mixed $default 默认值
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class RunServer extends Command
|
|||
escapeshellarg($root . DIRECTORY_SEPARATOR . 'router.php')
|
||||
);
|
||||
|
||||
$output->writeln(sprintf('ThinkPHP Development server is started On <http://%s:%s/>', '0.0.0.0' == $host ? '127.0.0.1' : $host, $port));
|
||||
$output->writeln(sprintf('ThinkPHP Development server is started On <http://%s:%s/>', $host, $port));
|
||||
$output->writeln(sprintf('You can exit with <info>`CTRL-C`</info>'));
|
||||
$output->writeln(sprintf('Document root is: %s', $root));
|
||||
passthru($command);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ use think\route\Url as UrlBuild;
|
|||
* @method static RuleItem redirect(string $rule, string $route = '', int $status = 301) 注册重定向路由
|
||||
* @method static \think\Route rest(string|array $name, array|bool $resource = []) rest方法定义和修改
|
||||
* @method static array|null getRest(string $name = null) 获取rest方法定义的参数
|
||||
* @method static RuleItem miss(string|Closure $route, string $method = '*') 注册未匹配路由规则后的处理
|
||||
* @method static RuleItem miss(string|\Closure $route, string $method = '*') 注册未匹配路由规则后的处理
|
||||
* @method static Response dispatch(\think\Request $request, Closure|bool $withRoute = true) 路由调度
|
||||
* @method static Dispatch|false check() 检测URL路由
|
||||
* @method static Dispatch url(string $url) 默认URL解析
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ class ModelService extends Service
|
|||
$model->setDateFormat($config->get('database.datetime_format', 'Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
$timeField = $config->get('database.datetime_field');
|
||||
if (!empty($timeField)) {
|
||||
[$createTime, $updateTime] = explode(',', $timeField);
|
||||
$model->setTimeField($createTime, $updateTime);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ class DbManager
|
|||
{
|
||||
if (isset($this->event[$event])) {
|
||||
foreach ($this->event[$event] as $callback) {
|
||||
call_user_func_array($callback, [$this]);
|
||||
call_user_func_array($callback, [$params]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ abstract class BaseQuery
|
|||
|
||||
$bind = $this->bind;
|
||||
$total = $this->count();
|
||||
$results = $this->options($options)->bind($bind)->page($page, $listRows)->select();
|
||||
$results = $total > 0 ? $this->options($options)->bind($bind)->page($page, $listRows)->select() : [];
|
||||
} elseif ($simple) {
|
||||
$results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select();
|
||||
$total = null;
|
||||
|
|
|
|||
|
|
@ -969,8 +969,8 @@ abstract class Builder
|
|||
$sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
|
||||
$bind = $query->getFieldsBindType();
|
||||
|
||||
foreach ($val as $item) {
|
||||
$val[] = $this->parseDataBind($query, $key, $item, $bind);
|
||||
foreach ($val as $k => $item) {
|
||||
$val[$k] = $this->parseDataBind($query, $key, $item, $bind);
|
||||
}
|
||||
|
||||
return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use Closure;
|
|||
use PDO;
|
||||
use PDOStatement;
|
||||
use think\db\exception\BindParamException;
|
||||
use think\db\exception\DbEventException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\PDOException;
|
||||
use think\Model;
|
||||
|
|
@ -865,18 +866,18 @@ abstract class PDOConnection extends Connection
|
|||
public function find(BaseQuery $query): array
|
||||
{
|
||||
// 事件回调
|
||||
$result = $this->db->trigger('before_find', $query);
|
||||
|
||||
if (!$result) {
|
||||
// 执行查询
|
||||
$resultSet = $this->pdoQuery($query, function ($query) {
|
||||
return $this->builder->select($query, true);
|
||||
});
|
||||
|
||||
$result = $resultSet[0] ?? [];
|
||||
try {
|
||||
$this->db->trigger('before_find', $query);
|
||||
} catch (DbEventException $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $result;
|
||||
// 执行查询
|
||||
$resultSet = $this->pdoQuery($query, function ($query) {
|
||||
return $this->builder->select($query, true);
|
||||
});
|
||||
|
||||
return $resultSet[0] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -908,16 +909,16 @@ abstract class PDOConnection extends Connection
|
|||
*/
|
||||
public function select(BaseQuery $query): array
|
||||
{
|
||||
$resultSet = $this->db->trigger('before_select', $query);
|
||||
|
||||
if (!$resultSet) {
|
||||
// 执行查询操作
|
||||
$resultSet = $this->pdoQuery($query, function ($query) {
|
||||
return $this->builder->select($query);
|
||||
});
|
||||
try {
|
||||
$this->db->trigger('before_select', $query);
|
||||
} catch (DbEventException $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $resultSet;
|
||||
// 执行查询操作
|
||||
return $this->pdoQuery($query, function ($query) {
|
||||
return $this->builder->select($query);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1158,7 +1159,7 @@ abstract class PDOConnection extends Connection
|
|||
|
||||
$field = $aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $this->builder->parseKey($query, $field, true) . ') AS think_' . strtolower($aggregate);
|
||||
|
||||
$result = $this->value($query, $field, 0, false);
|
||||
$result = $this->value($query, $field, 0);
|
||||
|
||||
return $force ? (float) $result : $result;
|
||||
}
|
||||
|
|
@ -1448,7 +1449,7 @@ abstract class PDOConnection extends Connection
|
|||
}
|
||||
$this->reConnectTimes = 0;
|
||||
} catch (\Throwable | \Exception $e) {
|
||||
if ($this->transTimes === 1 && $this->reConnectTimes < 4 && $this->isBreak($e)) {
|
||||
if (1 === $this->transTimes && $this->reConnectTimes < 4 && $this->isBreak($e)) {
|
||||
--$this->transTimes;
|
||||
++$this->reConnectTimes;
|
||||
$this->close()->startTrans();
|
||||
|
|
@ -1566,10 +1567,10 @@ abstract class PDOConnection extends Connection
|
|||
*/
|
||||
public function close()
|
||||
{
|
||||
$this->linkID = null;
|
||||
$this->linkWrite = null;
|
||||
$this->linkRead = null;
|
||||
$this->links = [];
|
||||
$this->linkID = null;
|
||||
$this->linkWrite = null;
|
||||
$this->linkRead = null;
|
||||
$this->links = [];
|
||||
$this->transTimes = 0;
|
||||
|
||||
$this->free();
|
||||
|
|
|
|||
|
|
@ -227,6 +227,8 @@ trait ResultOperation
|
|||
* @access public
|
||||
* @param array|string|Query|Closure $data 数据
|
||||
* @return array|Collection|static[]
|
||||
* @throws ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
*/
|
||||
public function selectOrFail($data = null)
|
||||
{
|
||||
|
|
@ -238,6 +240,8 @@ trait ResultOperation
|
|||
* @access public
|
||||
* @param array|string|Query|Closure $data 数据
|
||||
* @return array|Model|static
|
||||
* @throws ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
*/
|
||||
public function findOrFail($data = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\db\exception;
|
||||
|
||||
/**
|
||||
* Db事件异常
|
||||
*/
|
||||
class DbEventException extends DbException
|
||||
{
|
||||
}
|
||||
|
|
@ -245,11 +245,15 @@ abstract class Relation
|
|||
/**
|
||||
* 排除关联数据的字段
|
||||
* @access public
|
||||
* @param array $field 关联字段限制
|
||||
* @param array|string $field 关联字段限制
|
||||
* @return $this
|
||||
*/
|
||||
public function withoutField(array $field)
|
||||
public function withoutField($field)
|
||||
{
|
||||
if (is_string($field)) {
|
||||
$field = array_map('trim', explode(',', $field));
|
||||
}
|
||||
|
||||
$this->withoutField = $field;
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,21 @@ trait TimeStamp
|
|||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置时间字段名称
|
||||
* @access public
|
||||
* @param string $createTime
|
||||
* @param string $updateTime
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimeField(string $createTime, string $updateTime)
|
||||
{
|
||||
$this->createTime = $createTime;
|
||||
$this->updateTime = $updateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自动写入时间字段
|
||||
* @access public
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think\model\concern;
|
||||
|
||||
use think\db\BaseQuery as Query;
|
||||
use think\db\exception\DbException as Exception;
|
||||
|
||||
/**
|
||||
* 虚拟模型
|
||||
*/
|
||||
trait Virtual
|
||||
{
|
||||
/**
|
||||
* 获取当前模型的数据库查询对象
|
||||
* @access public
|
||||
* @param array $scope 设置不使用的全局查询范围
|
||||
* @return Query
|
||||
*/
|
||||
public function db($scope = []): Query
|
||||
{
|
||||
throw new Exception('virtual model not support db query');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段类型信息
|
||||
* @access public
|
||||
* @param string $field 字段名
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFieldType(string $field)
|
||||
{}
|
||||
|
||||
/**
|
||||
* 保存当前数据对象
|
||||
* @access public
|
||||
* @param array $data 数据
|
||||
* @param string $sequence 自增序列名
|
||||
* @return bool
|
||||
*/
|
||||
public function save(array $data = [], string $sequence = null): bool
|
||||
{
|
||||
// 数据对象赋值
|
||||
$this->setAttrs($data);
|
||||
|
||||
if ($this->isEmpty() || false === $this->trigger('BeforeWrite')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 写入回调
|
||||
$this->trigger('AfterWrite');
|
||||
|
||||
$this->exists(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除当前的记录
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
if (!$this->isExists() || $this->isEmpty() || false === $this->trigger('BeforeDelete')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 关联删除
|
||||
if (!empty($this->relationWrite)) {
|
||||
$this->autoRelationDelete();
|
||||
}
|
||||
|
||||
$this->trigger('AfterDelete');
|
||||
|
||||
$this->exists(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue