diff --git a/composer.lock b/composer.lock index 1ef4f45354b2835a13cae83afef123de04807ace..beb46bcf91e2ef2f4c3630251fa783c2139c68b3 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/public/core.php b/public/core.php index 3686cbea77739fec6fa2e646720e46a2866082af..e6f6b5ac83a91422f6f4c4824f08e9ed2480e501 100755 --- a/public/core.php +++ b/public/core.php @@ -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'); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 8b0de38db51984b5ede2c1b33ad8a490d6454808..c1718a106e4d480a590f9a3c62f04b4caccd9308 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -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'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 678bae683405ccb6e661bb893f333566fe437255..cc1bed61b4e3114ade70e3d41855bdb0f09eb4e9 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -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 ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 0bd5828e1d04b64c4377ec142b5469e6b7ac108b..1a79c1e1fa627000197de7844d4d95ea12423664 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -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" }, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 35563cff26006bfbd57b38b26ac0cc64546930ee..ff69f00fb7bca3cf8e4a8939b4d37dd9ef14fb8b 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -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( diff --git a/vendor/services.php b/vendor/services.php index 87148e8bce07edb140893bb7e682eb38839dd0d5..b6854db938d6fd13ecd676f32f76eae152ceaf74 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/topthink/framework/.travis.yml b/vendor/topthink/framework/.travis.yml index 28987af82211a2ca08191999dc76ec29c479f6b9..abaa2711b1559437c7bc48048f1af8af6bc5f897 100644 --- a/vendor/topthink/framework/.travis.yml +++ b/vendor/topthink/framework/.travis.yml @@ -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: diff --git a/vendor/topthink/framework/composer.json b/vendor/topthink/framework/composer.json index 9afc513a675b90d9cd934beb3955b6054ae42b16..4be2ae0ed2268b2a9276966c6d65b69d590747c8 100644 --- a/vendor/topthink/framework/composer.json +++ b/vendor/topthink/framework/composer.json @@ -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", diff --git a/vendor/topthink/framework/src/think/App.php b/vendor/topthink/framework/src/think/App.php index cdcfeb8d28debe726c4e4995a0d2d63b7659f7be..056a34112b3e713a857144f9341a71a8be5d176e 100644 --- a/vendor/topthink/framework/src/think/App.php +++ b/vendor/topthink/framework/src/think/App.php @@ -39,7 +39,7 @@ use think\initializer\RegisterService; */ class App extends Container { - const VERSION = '6.0.8'; + const VERSION = '6.0.9'; /** * 应用调试模式 diff --git a/vendor/topthink/framework/src/think/Event.php b/vendor/topthink/framework/src/think/Event.php index 6a0eb1f0e25b523bd8125cb5aeb9e0bb01442bce..3c70aadf25b62e9b8cdb7ecaf817a261fccd7f2e 100644 --- a/vendor/topthink/framework/src/think/Event.php +++ b/vendor/topthink/framework/src/think/Event.php @@ -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) { diff --git a/vendor/topthink/framework/src/think/Request.php b/vendor/topthink/framework/src/think/Request.php index a21976df11cbca67013ead570d6c33f060ef6810..1c15f6361902ef5c5dfb9c5303e37ead8f2fab0b 100644 --- a/vendor/topthink/framework/src/think/Request.php +++ b/vendor/topthink/framework/src/think/Request.php @@ -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 默认值 diff --git a/vendor/topthink/framework/src/think/console/command/RunServer.php b/vendor/topthink/framework/src/think/console/command/RunServer.php index 20a24662781183c4e04e249f1940a332024fe3cb..d507c1d8c0d5c0b77a77201155aaffc00d2bdc27 100644 --- a/vendor/topthink/framework/src/think/console/command/RunServer.php +++ b/vendor/topthink/framework/src/think/console/command/RunServer.php @@ -63,7 +63,7 @@ class RunServer extends Command escapeshellarg($root . DIRECTORY_SEPARATOR . 'router.php') ); - $output->writeln(sprintf('ThinkPHP Development server is started On ', '0.0.0.0' == $host ? '127.0.0.1' : $host, $port)); + $output->writeln(sprintf('ThinkPHP Development server is started On ', $host, $port)); $output->writeln(sprintf('You can exit with `CTRL-C`')); $output->writeln(sprintf('Document root is: %s', $root)); passthru($command); diff --git a/vendor/topthink/framework/src/think/facade/Route.php b/vendor/topthink/framework/src/think/facade/Route.php index 46bd7469ccd41364d0c1545848cec266a680baba..5a5b955db431ab77fcae5217d29c166096e2c6e8 100644 --- a/vendor/topthink/framework/src/think/facade/Route.php +++ b/vendor/topthink/framework/src/think/facade/Route.php @@ -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解析 diff --git a/vendor/topthink/framework/src/think/service/ModelService.php b/vendor/topthink/framework/src/think/service/ModelService.php index 87cfaf980af1703566e4f972376782dd43eca008..b517c4e052f4dfcc3635354facf7d31a997d5be0 100644 --- a/vendor/topthink/framework/src/think/service/ModelService.php +++ b/vendor/topthink/framework/src/think/service/ModelService.php @@ -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); + } + }); } } diff --git a/vendor/topthink/think-orm/src/DbManager.php b/vendor/topthink/think-orm/src/DbManager.php index 147d9f63eeb9d65c7e1c6a2567865f12803e66ca..f223cd2ccdedda2646e8cc3c122e6a6c6c9183e4 100644 --- a/vendor/topthink/think-orm/src/DbManager.php +++ b/vendor/topthink/think-orm/src/DbManager.php @@ -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]); } } } diff --git a/vendor/topthink/think-orm/src/db/BaseQuery.php b/vendor/topthink/think-orm/src/db/BaseQuery.php index 29bcbf2b55ddf13588d43d49954f5e1b66092c58..0e85e5a16ff3b54b794217dff85eedbf05c68fd8 100644 --- a/vendor/topthink/think-orm/src/db/BaseQuery.php +++ b/vendor/topthink/think-orm/src/db/BaseQuery.php @@ -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; diff --git a/vendor/topthink/think-orm/src/db/Builder.php b/vendor/topthink/think-orm/src/db/Builder.php index 73244f4d7e3181f7eaced062d27f3464b28fac65..1a1921f702a8f50020c036cca4eba64878f85f7a 100644 --- a/vendor/topthink/think-orm/src/db/Builder.php +++ b/vendor/topthink/think-orm/src/db/Builder.php @@ -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; diff --git a/vendor/topthink/think-orm/src/db/PDOConnection.php b/vendor/topthink/think-orm/src/db/PDOConnection.php index 0a51c0c4ff30a339ab8a02d195494dd84dcd27b6..60679afb7cee750c31625363792d35703ae41d63 100644 --- a/vendor/topthink/think-orm/src/db/PDOConnection.php +++ b/vendor/topthink/think-orm/src/db/PDOConnection.php @@ -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(); diff --git a/vendor/topthink/think-orm/src/db/concern/ResultOperation.php b/vendor/topthink/think-orm/src/db/concern/ResultOperation.php index 2860100de9e34c85d5de86844132bde6036153ee..de010939a077cb060b3719cdecda31d1562160bd 100644 --- a/vendor/topthink/think-orm/src/db/concern/ResultOperation.php +++ b/vendor/topthink/think-orm/src/db/concern/ResultOperation.php @@ -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) { diff --git a/vendor/topthink/think-orm/src/db/exception/DbEventException.php b/vendor/topthink/think-orm/src/db/exception/DbEventException.php new file mode 100644 index 0000000000000000000000000000000000000000..394a1e82fb7c5ba6ff3cb748329fabc9b89a72e0 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/DbEventException.php @@ -0,0 +1,19 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\exception; + +/** + * Db事件异常 + */ +class DbEventException extends DbException +{ +} diff --git a/vendor/topthink/think-orm/src/model/Relation.php b/vendor/topthink/think-orm/src/model/Relation.php index 0bd33d4a5cfa45c0a0358012989e66e2ad07e03d..1779896d7c2f93632c8187c86c03c5cee47a40fe 100644 --- a/vendor/topthink/think-orm/src/model/Relation.php +++ b/vendor/topthink/think-orm/src/model/Relation.php @@ -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; } diff --git a/vendor/topthink/think-orm/src/model/concern/TimeStamp.php b/vendor/topthink/think-orm/src/model/concern/TimeStamp.php index e207961f37d3ff6cb38514082f39a0ed84a07084..2492e0661d56bded1ff7db3e9e692cfe68b284ab 100644 --- a/vendor/topthink/think-orm/src/model/concern/TimeStamp.php +++ b/vendor/topthink/think-orm/src/model/concern/TimeStamp.php @@ -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 diff --git a/vendor/topthink/think-orm/src/model/concern/Virtual.php b/vendor/topthink/think-orm/src/model/concern/Virtual.php new file mode 100644 index 0000000000000000000000000000000000000000..66cdfb7ea3cfa5f968223eb865c9498f1d4902d3 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/Virtual.php @@ -0,0 +1,90 @@ + +// +---------------------------------------------------------------------- +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; + } + +}