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
8af01f20
Commit
8af01f20
authored
Sep 17, 2018
by
feixiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实体分表逻辑修改
parent
488d0b21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
src/Common/Entity/CommonEntity.php
+14
-7
No files found.
src/Common/Entity/CommonEntity.php
View file @
8af01f20
...
@@ -93,12 +93,17 @@ class CommonEntity extends Model
...
@@ -93,12 +93,17 @@ class CommonEntity extends Model
//获取注解里的table
//获取注解里的table
$res
=
new
\ReflectionClass
(
static
::
class
);
$res
=
new
\ReflectionClass
(
static
::
class
);
self
::
$commentString
=
$res
->
getDocComment
();
$commentString
=
$res
->
getDocComment
();
if
(
false
!==
strpos
(
self
::
$commentString
,
"
{
split
}
"
)
&&
!
App
::
$isInTest
)
{
if
(
(
false
!==
strpos
(
$commentString
,
"
{
split
}
"
)
||
false
!==
strpos
(
$commentString
,
"@Split()"
)
)
&&
!
App
::
$isInTest
)
{
$dbNum
=
self
::
getDbNum
();
$dbNum
=
self
::
getDbNum
();
$tableName
=
self
::
getTableName
()
.
'_'
.
$dbNum
;
$tableName
=
self
::
getTableName
(
$commentString
)
.
'_'
.
$dbNum
;
self
::
setTableName
(
$tableName
);
//
self::setTableName($tableName);
return
$tableName
;
return
$tableName
;
}
else
{
}
else
{
...
@@ -143,9 +148,10 @@ class CommonEntity extends Model
...
@@ -143,9 +148,10 @@ class CommonEntity extends Model
* 获取原始表名
* 获取原始表名
* @return string
* @return string
*/
*/
protected
static
function
getTableName
()
protected
static
function
getTableName
(
$commentString
=
''
)
{
{
preg_match
(
'/(?<=Table\(name=").*(?="\))/'
,
self
::
$commentString
,
$matches
);
$commentString
=
$commentString
===
''
?
self
::
$commentString
:
$commentString
;
preg_match
(
'/(?<=Table\(name=").*(?="\))/'
,
$commentString
,
$matches
);
return
$tableName
=
isset
(
$matches
[
0
])
?
$matches
[
0
]
:
''
;
return
$tableName
=
isset
(
$matches
[
0
])
?
$matches
[
0
]
:
''
;
}
}
}
}
\ No newline at end of file
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