Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tencent
services
Commits
47edf098
Commit
47edf098
authored
Nov 05, 2018
by
feixiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对照分表处理
parent
8c9fb173
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
src/Common/Entity/CommonEntity.php
+29
-3
src/Common/Entity/Split.php
+1
-1
No files found.
src/Common/Entity/CommonEntity.php
View file @
47edf098
...
...
@@ -103,13 +103,39 @@ class CommonEntity extends Model
$dbNum
=
self
::
getDbNum
();
$tableName
=
self
::
getTableName
(
$commentString
)
.
'_'
.
$dbNum
;
//self::setTableName($tableName);
return
$tableName
;
}
else
{
return
self
::
getTableName
(
$commentString
);
$tableName
=
self
::
getTableName
(
$commentString
);
}
$newTableName
=
self
::
newTableName
();
if
(
$tableName
!=
$newTableName
)
{
//校验新的分表规则
App
::
error
(
"[新分表异常][对比失败]oldFunction"
.
$tableName
.
'new function'
.
$newTableName
);
}
return
$tableName
;
}
private
static
function
newTableName
()
{
if
(
empty
(
RequestContext
::
getContextData
())
)
{
//初始化不做处理
return
;
}
$entityCollector
=
EntityCollector
::
getCollector
();
$splitCollector
=
SplitCollector
::
getCollector
();
//分表搜集器
$className
=
static
::
class
;
$tableName
=
$entityCollector
[
$className
][
'table'
][
'name'
];
if
(
isset
(
$splitCollector
[
$className
])
)
{
//分表
$dbNum
=
(
new
Split
())
->
getDbNum
(
$className
);
$tableName
=
$tableName
.
'_'
.
$dbNum
;
}
return
$tableName
;
}
/**
...
...
src/Common/Entity/Split.php
View file @
47edf098
...
...
@@ -58,7 +58,7 @@ class Split
return
$tableName
;
}
p
rivate
function
getDbNum
(
$className
)
p
ublic
function
getDbNum
(
$className
)
{
$splitCollector
=
SplitCollector
::
getCollector
();
$splitNum
=
$splitCollector
[
$className
][
'num'
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment