@@ -29,7 +29,12 @@ public function parseModelTable($model,$classReflect,$methodName=""){
29
29
try {
30
30
// 获取所有模型属性
31
31
$ propertys = $ classReflect ->getDefaultProperties ();
32
- $ table =$ this ->getTableDocument ($ model , $ propertys );
32
+ $ tableName = $ model ->getTable ();
33
+ $ configTablePrefix = !empty ($ config ['database ' ]) && !empty ($ config ['database ' ]['prefix ' ])?$ config ['database ' ]['prefix ' ]:"" ;
34
+ if (!empty ($ configTablePrefix ) && strpos ($ tableName , $ configTablePrefix ) === false ){
35
+ $ tableName = $ configTablePrefix .$ model ->getTable ();
36
+ }
37
+ $ table =$ this ->getTableDocument ($ tableName , $ propertys );
33
38
if (empty ($ methodName )){
34
39
return $ table ;
35
40
}
@@ -101,22 +106,17 @@ public static function getModelClass($namespaceName)
101
106
102
107
/**
103
108
* 获取模型注解数据
104
- * @param $model
109
+ * @param $tableName
105
110
* @param $propertys
106
111
* @return array
107
112
*/
108
- protected function getTableDocument ($ model ,array $ propertys ):array
113
+ public function getTableDocument ($ tableName ,array $ propertys ):array
109
114
{
110
115
$ config = $ this ->config ;
111
116
$ fieldComment = [];
112
117
if (empty ($ config ['database_query_function ' ])){
113
118
throw new ErrorException ("not datatable_query_function config " );
114
119
}
115
- $ tableName = $ model ->getTable ();
116
- $ configTablePrefix = !empty ($ config ['database ' ]) && !empty ($ config ['database ' ]['prefix ' ])?$ config ['database ' ]['prefix ' ]:"" ;
117
- if (!empty ($ configTablePrefix ) && strpos ($ tableName , $ configTablePrefix ) === false ){
118
- $ tableName = $ configTablePrefix .$ model ->getTable ();
119
- }
120
120
$ tableColumns = $ config ['database_query_function ' ]("SHOW FULL COLUMNS FROM " . $ tableName );
121
121
foreach ($ tableColumns as $ columns ) {
122
122
$ columns = Helper::objectToArray ($ columns );
0 commit comments