Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
02f36421
ShopXO
项目概览
纵之格
/
ShopXO
通知
394
Star
16
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
02f36421
编写于
1月 24, 2022
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
类库更新
上级
921d28f9
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
130 addition
and
102 deletion
+130
-102
vendor/composer/autoload_psr4.php
vendor/composer/autoload_psr4.php
+1
-1
vendor/composer/autoload_static.php
vendor/composer/autoload_static.php
+3
-3
vendor/composer/installed.json
vendor/composer/installed.json
+14
-14
vendor/composer/installed.php
vendor/composer/installed.php
+8
-8
vendor/services.php
vendor/services.php
+1
-1
vendor/topthink/framework/src/think/App.php
vendor/topthink/framework/src/think/App.php
+1
-1
vendor/topthink/framework/src/think/Env.php
vendor/topthink/framework/src/think/Env.php
+1
-1
vendor/topthink/framework/src/think/cache/Driver.php
vendor/topthink/framework/src/think/cache/Driver.php
+1
-1
vendor/topthink/framework/src/think/console/input/Option.php
vendor/topthink/framework/src/think/console/input/Option.php
+14
-14
vendor/topthink/framework/src/think/route/Resource.php
vendor/topthink/framework/src/think/route/Resource.php
+1
-1
vendor/topthink/framework/src/think/route/Rule.php
vendor/topthink/framework/src/think/route/Rule.php
+18
-0
vendor/topthink/framework/src/think/route/RuleItem.php
vendor/topthink/framework/src/think/route/RuleItem.php
+2
-2
vendor/topthink/think-orm/src/db/Fetch.php
vendor/topthink/think-orm/src/db/Fetch.php
+2
-4
vendor/topthink/think-orm/src/db/builder/Sqlite.php
vendor/topthink/think-orm/src/db/builder/Sqlite.php
+14
-10
vendor/topthink/think-orm/src/db/connector/Sqlite.php
vendor/topthink/think-orm/src/db/connector/Sqlite.php
+1
-1
vendor/topthink/think-orm/src/model/concern/Attribute.php
vendor/topthink/think-orm/src/model/concern/Attribute.php
+3
-0
vendor/topthink/think-orm/src/model/relation/BelongsTo.php
vendor/topthink/think-orm/src/model/relation/BelongsTo.php
+5
-6
vendor/topthink/think-orm/src/model/relation/BelongsToMany.php
...r/topthink/think-orm/src/model/relation/BelongsToMany.php
+28
-28
vendor/topthink/think-orm/src/model/relation/HasManyThrough.php
.../topthink/think-orm/src/model/relation/HasManyThrough.php
+7
-1
vendor/topthink/think-orm/src/model/relation/HasOne.php
vendor/topthink/think-orm/src/model/relation/HasOne.php
+5
-5
未找到文件。
vendor/composer/autoload_psr4.php
浏览文件 @
02f36421
...
...
@@ -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'
),
'ZipStream\\'
=>
array
(
$vendorDir
.
'/maennchen/zipstream-php/src'
),
'Symfony\\Polyfill\\Php80\\'
=>
array
(
$vendorDir
.
'/symfony/polyfill-php80'
),
...
...
vendor/composer/autoload_static.php
浏览文件 @
02f36421
...
...
@@ -81,10 +81,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
(
...
...
vendor/composer/installed.json
浏览文件 @
02f36421
...
...
@@ -1441,17 +1441,17 @@
},
{
"name"
:
"topthink/framework"
,
"version"
:
"v6.0.1
1
"
,
"version_normalized"
:
"6.0.1
1
.0"
,
"version"
:
"v6.0.1
2
"
,
"version_normalized"
:
"6.0.1
2
.0"
,
"source"
:
{
"type"
:
"git"
,
"url"
:
"https://github.com/top-think/framework.git"
,
"reference"
:
"
d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb
"
"reference"
:
"
e478316ac843c1a884a3b3a7a94db17c4001ff5c
"
},
"dist"
:
{
"type"
:
"zip"
,
"url"
:
"https://api.github.com/repos/top-think/framework/zipball/
d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb
"
,
"reference"
:
"
d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb
"
,
"url"
:
"https://api.github.com/repos/top-think/framework/zipball/
e478316ac843c1a884a3b3a7a94db17c4001ff5c
"
,
"reference"
:
"
e478316ac843c1a884a3b3a7a94db17c4001ff5c
"
,
"shasum"
:
""
,
"mirrors"
:
[
{
...
...
@@ -1479,7 +1479,7 @@
"mockery/mockery"
:
"^1.2"
,
"phpunit/phpunit"
:
"^7.0"
},
"time"
:
"202
1-12-31T09:14:28
+00:00"
,
"time"
:
"202
2-01-21T06:31:07
+00:00"
,
"type"
:
"library"
,
"installation-source"
:
"dist"
,
"autoload"
:
{
...
...
@@ -1511,7 +1511,7 @@
],
"support"
:
{
"issues"
:
"https://github.com/top-think/framework/issues"
,
"source"
:
"https://github.com/top-think/framework/tree/v6.0.1
1
"
"source"
:
"https://github.com/top-think/framework/tree/v6.0.1
2
"
},
"install-path"
:
"../topthink/framework"
},
...
...
@@ -1623,17 +1623,17 @@
},
{
"name"
:
"topthink/think-orm"
,
"version"
:
"v2.0.5
0
"
,
"version_normalized"
:
"2.0.5
0
.0"
,
"version"
:
"v2.0.5
1
"
,
"version_normalized"
:
"2.0.5
1
.0"
,
"source"
:
{
"type"
:
"git"
,
"url"
:
"https://github.com/top-think/think-orm.git"
,
"reference"
:
"
091ad5e023c15fcce4ceaea2f3814bdf71045cde
"
"reference"
:
"
149d266acdc4b2f07c6a94f1733b6b97d340e0e2
"
},
"dist"
:
{
"type"
:
"zip"
,
"url"
:
"https://api.github.com/repos/top-think/think-orm/zipball/
091ad5e023c15fcce4ceaea2f3814bdf71045cde
"
,
"reference"
:
"
091ad5e023c15fcce4ceaea2f3814bdf71045cde
"
,
"url"
:
"https://api.github.com/repos/top-think/think-orm/zipball/
149d266acdc4b2f07c6a94f1733b6b97d340e0e2
"
,
"reference"
:
"
149d266acdc4b2f07c6a94f1733b6b97d340e0e2
"
,
"shasum"
:
""
,
"mirrors"
:
[
{
...
...
@@ -1653,7 +1653,7 @@
"require-dev"
:
{
"phpunit/phpunit"
:
"^7|^8|^9.5"
},
"time"
:
"2022-01-
06T02:48:16
+00:00"
,
"time"
:
"2022-01-
21T06:25:25
+00:00"
,
"type"
:
"library"
,
"installation-source"
:
"dist"
,
"autoload"
:
{
...
...
@@ -1681,7 +1681,7 @@
],
"support"
:
{
"issues"
:
"https://github.com/top-think/think-orm/issues"
,
"source"
:
"https://github.com/top-think/think-orm/tree/v2.0.5
0
"
"source"
:
"https://github.com/top-think/think-orm/tree/v2.0.5
1
"
},
"install-path"
:
"../topthink/think-orm"
},
...
...
vendor/composer/installed.php
浏览文件 @
02f36421
...
...
@@ -5,7 +5,7 @@
'type'
=>
'project'
,
'install_path'
=>
__DIR__
.
'/../../'
,
'aliases'
=>
array
(),
'reference'
=>
'
5979814ba42ca1796f517662de1e19f6736a1182
'
,
'reference'
=>
'
921d28f9ce7fcc47b9b8312f92080643eddfe75a
'
,
'name'
=>
'shopxo/shopxo'
,
'dev'
=>
true
,
),
...
...
@@ -160,7 +160,7 @@
'type'
=>
'project'
,
'install_path'
=>
__DIR__
.
'/../../'
,
'aliases'
=>
array
(),
'reference'
=>
'
5979814ba42ca1796f517662de1e19f6736a1182
'
,
'reference'
=>
'
921d28f9ce7fcc47b9b8312f92080643eddfe75a
'
,
'dev_requirement'
=>
false
,
),
'symfony/polyfill-mbstring'
=>
array
(
...
...
@@ -200,12 +200,12 @@
'dev_requirement'
=>
true
,
),
'topthink/framework'
=>
array
(
'pretty_version'
=>
'v6.0.1
1
'
,
'version'
=>
'6.0.1
1
.0'
,
'pretty_version'
=>
'v6.0.1
2
'
,
'version'
=>
'6.0.1
2
.0'
,
'type'
=>
'library'
,
'install_path'
=>
__DIR__
.
'/../topthink/framework'
,
'aliases'
=>
array
(),
'reference'
=>
'
d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb
'
,
'reference'
=>
'
e478316ac843c1a884a3b3a7a94db17c4001ff5c
'
,
'dev_requirement'
=>
false
,
),
'topthink/think-helper'
=>
array
(
...
...
@@ -227,12 +227,12 @@
'dev_requirement'
=>
false
,
),
'topthink/think-orm'
=>
array
(
'pretty_version'
=>
'v2.0.5
0
'
,
'version'
=>
'2.0.5
0
.0'
,
'pretty_version'
=>
'v2.0.5
1
'
,
'version'
=>
'2.0.5
1
.0'
,
'type'
=>
'library'
,
'install_path'
=>
__DIR__
.
'/../topthink/think-orm'
,
'aliases'
=>
array
(),
'reference'
=>
'
091ad5e023c15fcce4ceaea2f3814bdf71045cde
'
,
'reference'
=>
'
149d266acdc4b2f07c6a94f1733b6b97d340e0e2
'
,
'dev_requirement'
=>
false
,
),
'topthink/think-template'
=>
array
(
...
...
vendor/services.php
浏览文件 @
02f36421
<?php
// This file is automatically generated at:2022-01-
10 18:17:36
// This file is automatically generated at:2022-01-
24 15:08:07
declare
(
strict_types
=
1
);
return
array
(
0
=>
'think\\app\\Service'
,
...
...
vendor/topthink/framework/src/think/App.php
浏览文件 @
02f36421
...
...
@@ -39,7 +39,7 @@ use think\initializer\RegisterService;
*/
class
App
extends
Container
{
const
VERSION
=
'6.0.1
0
LTS'
;
const
VERSION
=
'6.0.1
2
LTS'
;
/**
* 应用调试模式
...
...
vendor/topthink/framework/src/think/Env.php
浏览文件 @
02f36421
...
...
@@ -188,7 +188,7 @@ class Env implements ArrayAccess
}
#[\ReturnTypeWillChange]
public
function
offsetUnset
(
$name
)
public
function
offsetUnset
(
$name
)
:
void
{
throw
new
Exception
(
'not support: unset'
);
}
...
...
vendor/topthink/framework/src/think/cache/Driver.php
浏览文件 @
02f36421
...
...
@@ -249,7 +249,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface
* @param string $data 缓存数据
* @return mixed
*/
protected
function
unserialize
(
string
$data
)
protected
function
unserialize
(
$data
)
{
if
(
is_numeric
(
$data
))
{
return
$data
;
...
...
vendor/topthink/framework/src/think/console/input/Option.php
浏览文件 @
02f36421
...
...
@@ -18,7 +18,7 @@ namespace think\console\input;
class
Option
{
// 无需传值
const
VALUE_NONE
=
1
;
const
VALUE_NONE
=
1
;
// 必须传值
const
VALUE_REQUIRED
=
2
;
// 可选传值
...
...
@@ -30,13 +30,13 @@ class Option
* 选项名
* @var string
*/
private
$name
;
private
$name
=
''
;
/**
* 选项短名称
* @var string
*/
private
$shortcut
;
private
$shortcut
=
''
;
/**
* 选项类型
...
...
@@ -54,7 +54,7 @@ class Option
* 选项描述
* @var string
*/
private
$description
;
private
$description
=
''
;
/**
* 构造方法
...
...
@@ -76,10 +76,10 @@ class Option
}
if
(
empty
(
$shortcut
))
{
$shortcut
=
null
;
$shortcut
=
''
;
}
if
(
null
!==
$shortcut
)
{
if
(
''
!==
$shortcut
)
{
if
(
is_array
(
$shortcut
))
{
$shortcut
=
implode
(
'|'
,
$shortcut
);
}
...
...
@@ -114,7 +114,7 @@ class Option
* 获取短名称
* @return string
*/
public
function
getShortcut
()
public
function
getShortcut
()
:
string
{
return
$this
->
shortcut
;
}
...
...
@@ -123,7 +123,7 @@ class Option
* 获取选项名
* @return string
*/
public
function
getName
()
public
function
getName
()
:
string
{
return
$this
->
name
;
}
...
...
@@ -132,7 +132,7 @@ class Option
* 是否可以设置值
* @return bool 类型不是 self::VALUE_NONE 的时候返回true,其他均返回false
*/
public
function
acceptValue
()
public
function
acceptValue
()
:
bool
{
return
$this
->
isValueRequired
()
||
$this
->
isValueOptional
();
}
...
...
@@ -141,7 +141,7 @@ class Option
* 是否必须
* @return bool 类型是 self::VALUE_REQUIRED 的时候返回true,其他均返回false
*/
public
function
isValueRequired
()
public
function
isValueRequired
()
:
bool
{
return
self
::
VALUE_REQUIRED
===
(
self
::
VALUE_REQUIRED
&
$this
->
mode
);
}
...
...
@@ -150,7 +150,7 @@ class Option
* 是否可选
* @return bool 类型是 self::VALUE_OPTIONAL 的时候返回true,其他均返回false
*/
public
function
isValueOptional
()
public
function
isValueOptional
()
:
bool
{
return
self
::
VALUE_OPTIONAL
===
(
self
::
VALUE_OPTIONAL
&
$this
->
mode
);
}
...
...
@@ -159,7 +159,7 @@ class Option
* 选项值是否接受数组
* @return bool 类型是 self::VALUE_IS_ARRAY 的时候返回true,其他均返回false
*/
public
function
isArray
()
public
function
isArray
()
:
bool
{
return
self
::
VALUE_IS_ARRAY
===
(
self
::
VALUE_IS_ARRAY
&
$this
->
mode
);
}
...
...
@@ -199,7 +199,7 @@ class Option
* 获取描述文字
* @return string
*/
public
function
getDescription
()
public
function
getDescription
()
:
string
{
return
$this
->
description
;
}
...
...
@@ -209,7 +209,7 @@ class Option
* @param Option $option
* @return bool
*/
public
function
equals
(
Option
$option
)
public
function
equals
(
Option
$option
)
:
bool
{
return
$option
->
getName
()
===
$this
->
getName
()
&&
$option
->
getShortcut
()
===
$this
->
getShortcut
()
...
...
vendor/topthink/framework/src/think/route/Resource.php
浏览文件 @
02f36421
...
...
@@ -213,7 +213,7 @@ class Resource extends RuleGroup
}
/**
* 绑定资源
模型
* 绑定资源
中间件
* @access public
* @param array|string $name 资源类型或者中间件定义
* @param array|string $middleware 中间件定义
...
...
vendor/topthink/framework/src/think/route/Rule.php
浏览文件 @
02f36421
...
...
@@ -532,6 +532,17 @@ abstract class Rule
return
$this
->
setOption
(
'view'
,
$view
);
}
/**
* 通过闭包检查路由是否匹配
* @access public
* @param callable $match 闭包
* @return $this
*/
public
function
match
(
callable
$match
)
{
return
$this
->
setOption
(
'match'
,
$match
);
}
/**
* 设置路由完整匹配
* @access public
...
...
@@ -694,6 +705,13 @@ abstract class Rule
*/
protected
function
checkOption
(
array
$option
,
Request
$request
):
bool
{
// 检查当前路由是否匹配
if
(
isset
(
$option
[
'match'
])
&&
is_callable
(
$option
[
'match'
]))
{
if
(
false
===
$option
[
'match'
](
$this
,
$request
))
{
return
false
;
}
}
// 请求类型检测
if
(
!
empty
(
$option
[
'method'
]))
{
if
(
is_string
(
$option
[
'method'
])
&&
false
===
stripos
(
$option
[
'method'
],
$request
->
method
()))
{
...
...
vendor/topthink/framework/src/think/route/RuleItem.php
浏览文件 @
02f36421
...
...
@@ -196,7 +196,7 @@ class RuleItem extends Rule
$url
=
$this
->
urlSuffixCheck
(
$request
,
$url
,
$option
);
if
(
is_null
(
$match
))
{
$match
=
$this
->
m
atch
(
$url
,
$option
,
$pattern
,
$completeMatch
);
$match
=
$this
->
checkM
atch
(
$url
,
$option
,
$pattern
,
$completeMatch
);
}
if
(
false
!==
$match
)
{
...
...
@@ -252,7 +252,7 @@ class RuleItem extends Rule
* @param bool $completeMatch 是否完全匹配
* @return array|false
*/
private
function
m
atch
(
string
$url
,
array
$option
,
array
$pattern
,
bool
$completeMatch
)
private
function
checkM
atch
(
string
$url
,
array
$option
,
array
$pattern
,
bool
$completeMatch
)
{
if
(
isset
(
$option
[
'complete_match'
]))
{
$completeMatch
=
$option
[
'complete_match'
];
...
...
vendor/topthink/think-orm/src/db/Fetch.php
浏览文件 @
02f36421
...
...
@@ -421,10 +421,8 @@ class Fetch
if
(
!
empty
(
$options
[
'group'
]))
{
// 支持GROUP
$bind
=
$this
->
query
->
getBind
();
$subSql
=
$this
->
query
->
options
(
$options
)
->
field
(
'count('
.
$field
.
') AS think_count'
)
->
bind
(
$bind
)
->
buildSql
();
$query
=
$this
->
query
->
newQuery
()
->
table
([
$subSql
=>
'_group_count_'
]);
$subSql
=
$this
->
query
->
field
(
'count('
.
$field
.
') AS think_count'
)
->
buildSql
();
$query
=
$this
->
query
->
newQuery
()
->
table
([
$subSql
=>
'_group_count_'
]);
return
$query
->
fetchsql
()
->
aggregate
(
'COUNT'
,
'*'
);
}
else
{
...
...
vendor/topthink/think-orm/src/db/builder/Sqlite.php
浏览文件 @
02f36421
...
...
@@ -24,8 +24,8 @@ class Sqlite extends Builder
/**
* limit
* @access public
* @param
Query $query
查询对象
* @param
mixed
$limit
* @param
Query $query
查询对象
* @param
mixed
$limit
* @return string
*/
public
function
parseLimit
(
Query
$query
,
string
$limit
):
string
...
...
@@ -47,7 +47,7 @@ class Sqlite extends Builder
/**
* 随机排序
* @access protected
* @param
Query $query
查询对象
* @param
Query $query
查询对象
* @return string
*/
protected
function
parseRand
(
Query
$query
):
string
...
...
@@ -58,9 +58,9 @@ class Sqlite extends Builder
/**
* 字段和表名处理
* @access public
* @param
Query $query
查询对象
* @param
mixed $key
字段名
* @param
bool $strict
严格检测
* @param
Query $query
查询对象
* @param
mixed $key
字段名
* @param
bool $strict
严格检测
* @return string
*/
public
function
parseKey
(
Query
$query
,
$key
,
bool
$strict
=
false
):
string
...
...
@@ -73,7 +73,7 @@ class Sqlite extends Builder
$key
=
trim
(
$key
);
if
(
strpos
(
$key
,
'.'
))
{
if
(
strpos
(
$key
,
'.'
)
&&
!
preg_match
(
'/[,\'\"\(\)`\s]/'
,
$key
)
)
{
[
$table
,
$key
]
=
explode
(
'.'
,
$key
,
2
);
$alias
=
$query
->
getOptions
(
'alias'
);
...
...
@@ -88,8 +88,12 @@ class Sqlite extends Builder
}
}
if
(
'*'
!=
$key
&&
!
preg_match
(
'/[,\'\"\*\(\)`.\s]/'
,
$key
))
{
$key
=
'`'
.
$key
.
'`'
;
}
if
(
isset
(
$table
))
{
$key
=
$table
.
'
.'
.
$key
;
$key
=
'`'
.
$table
.
'`
.'
.
$key
;
}
return
$key
;
...
...
@@ -98,8 +102,8 @@ class Sqlite extends Builder
/**
* 设置锁机制
* @access protected
* @param
Query $query 查询对象
* @param
bool|string $lock
* @param Query $query 查询对象
* @param bool|string $lock
* @return string
*/
protected
function
parseLock
(
Query
$query
,
$lock
=
false
):
string
...
...
vendor/topthink/think-orm/src/db/connector/Sqlite.php
浏览文件 @
02f36421
...
...
@@ -42,7 +42,7 @@ class Sqlite extends PDOConnection
public
function
getFields
(
string
$tableName
):
array
{
[
$tableName
]
=
explode
(
' '
,
$tableName
);
$sql
=
'PRAGMA table_info(
'
.
$tableName
.
' )'
;
$sql
=
'PRAGMA table_info(
\''
.
$tableName
.
'\
' )'
;
$pdo
=
$this
->
getPDOStatement
(
$sql
);
$result
=
$pdo
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
...
...
vendor/topthink/think-orm/src/model/concern/Attribute.php
浏览文件 @
02f36421
...
...
@@ -382,6 +382,9 @@ trait Attribute
}
elseif
(
isset
(
$this
->
type
[
$name
]))
{
// 类型转换
$value
=
$this
->
writeTransform
(
$value
,
$this
->
type
[
$name
]);
}
elseif
(
is_object
(
$value
)
&&
method_exists
(
$value
,
'__toString'
))
{
// 对象类型
$value
=
$value
->
__toString
();
}
// 设置数据对象属性
...
...
vendor/topthink/think-orm/src/model/relation/BelongsTo.php
浏览文件 @
02f36421
...
...
@@ -236,12 +236,11 @@ class BelongsTo extends OneToOne
$relationModel
->
exists
(
true
);
}
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
if
(
!
empty
(
$this
->
bindAttr
))
{
// 绑定关联属性
$this
->
bindAttr
(
$result
,
$relationModel
);
}
else
{
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
}
}
}
...
...
@@ -277,12 +276,12 @@ class BelongsTo extends OneToOne
$relationModel
->
exists
(
true
);
}
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
if
(
!
empty
(
$this
->
bindAttr
))
{
// 绑定关联属性
$this
->
bindAttr
(
$result
,
$relationModel
);
}
else
{
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
}
}
...
...
vendor/topthink/think-orm/src/model/relation/BelongsToMany.php
浏览文件 @
02f36421
...
...
@@ -137,6 +137,30 @@ class BelongsToMany extends Relation
->
setParent
(
clone
$this
->
parent
);
}
/**
* 组装Pivot模型
* @access public
* @param Model $result 模型对象
* @return array
*/
protected
function
matchPivot
(
Model
$result
):
array
{
$pivot
=
[];
foreach
(
$result
->
getData
()
as
$key
=>
$val
)
{
if
(
strpos
(
$key
,
'__'
))
{
[
$name
,
$attr
]
=
explode
(
'__'
,
$key
,
2
);
if
(
'pivot'
==
$name
)
{
$pivot
[
$attr
]
=
$val
;
unset
(
$result
->
$key
);
}
}
}
$result
->
setRelation
(
$this
->
pivotDataName
,
$this
->
newPivot
(
$pivot
));
return
$pivot
;
}
/**
* 根据关联条件查询当前模型
* @access public
...
...
@@ -326,24 +350,13 @@ class BelongsToMany extends Relation
// 组装模型数据
$data
=
[];
foreach
(
$list
as
$set
)
{
$pivot
=
[];
foreach
(
$set
->
getData
()
as
$key
=>
$val
)
{
if
(
strpos
(
$key
,
'__'
))
{
[
$name
,
$attr
]
=
explode
(
'__'
,
$key
,
2
);
if
(
'pivot'
==
$name
)
{
$pivot
[
$attr
]
=
$val
;
unset
(
$set
->
$key
);
}
}
}
$key
=
$pivot
[
$this
->
localKey
];
$pivot
=
$this
->
matchPivot
(
$set
);
$key
=
$pivot
[
$this
->
localKey
];
if
(
$this
->
withLimit
&&
isset
(
$data
[
$key
])
&&
count
(
$data
[
$key
])
>=
$this
->
withLimit
)
{
continue
;
}
$set
->
setRelation
(
$this
->
pivotDataName
,
$this
->
newPivot
(
$pivot
));
$data
[
$key
][]
=
$set
;
}
...
...
@@ -594,21 +607,8 @@ class BelongsToMany extends Relation
$foreignKey
=
$this
->
foreignKey
;
$localKey
=
$this
->
localKey
;
$this
->
query
->
getModel
()
->
filter
(
function
(
$result
,
$options
)
{
$pivot
=
[];
foreach
(
$result
->
getData
()
as
$key
=>
$val
)
{
if
(
strpos
(
$key
,
'__'
))
{
[
$name
,
$attr
]
=
explode
(
'__'
,
$key
,
2
);
if
(
'pivot'
==
$name
)
{
$pivot
[
$attr
]
=
$val
;
unset
(
$result
->
$key
);
}
}
}
$result
->
setRelation
(
$this
->
pivotDataName
,
$this
->
newPivot
(
$pivot
));
$this
->
query
->
filter
(
function
(
$result
,
$options
)
{
$this
->
matchPivot
(
$result
);
});
// 关联查询
...
...
vendor/topthink/think-orm/src/model/relation/HasManyThrough.php
浏览文件 @
02f36421
...
...
@@ -258,8 +258,14 @@ class HasManyThrough extends Relation
$closure
(
$this
->
getClosureType
(
$closure
));
}
$throughKey
=
$this
->
throughKey
;
if
(
$this
->
baseQuery
)
{
$throughKey
=
Str
::
snake
(
class_basename
(
$this
->
model
))
.
"."
.
$this
->
throughKey
;
}
$list
=
$this
->
query
->
where
(
$th
is
->
th
roughKey
,
'in'
,
$keys
)
->
where
(
$throughKey
,
'in'
,
$keys
)
->
cache
(
$cache
[
0
]
??
false
,
$cache
[
1
]
??
null
,
$cache
[
2
]
??
null
)
->
select
();
...
...
vendor/topthink/think-orm/src/model/relation/HasOne.php
浏览文件 @
02f36421
...
...
@@ -234,13 +234,12 @@ class HasOne extends OneToOne
$relationModel
->
setParent
(
clone
$result
);
$relationModel
->
exists
(
true
);
}
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
if
(
!
empty
(
$this
->
bindAttr
))
{
// 绑定关联属性
$this
->
bindAttr
(
$result
,
$relationModel
);
}
else
{
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
}
}
}
...
...
@@ -276,11 +275,12 @@ class HasOne extends OneToOne
$relationModel
->
exists
(
true
);
}
// 设置关联属性
$result
->
setRelation
(
$relation
,
$relationModel
);
if
(
!
empty
(
$this
->
bindAttr
))
{
// 绑定关联属性
$this
->
bindAttr
(
$result
,
$relationModel
);
}
else
{
$result
->
setRelation
(
$relation
,
$relationModel
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录