From 0bd4fe2b10fc309a7574c90cff98f9fe60c3ccf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E6=B6=A6?= Date: Tue, 19 Feb 2019 09:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=97=B6-override=E6=8C=87=E5=AE=9A=E4=B8=BA=E9=9D=9E?= =?UTF-8?q?bool=E5=80=BC=EF=BC=8C=E5=8F=AF=E8=83=BD=E6=9C=89=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=B2=A1=E7=94=9F=E6=88=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Tool/Tools/Generate/Model/ModelGenerate.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Tool/Tools/Generate/Model/ModelGenerate.php b/src/Tool/Tools/Generate/Model/ModelGenerate.php index 829343ce7e..b16d77e147 100644 --- a/src/Tool/Tools/Generate/Model/ModelGenerate.php +++ b/src/Tool/Tools/Generate/Model/ModelGenerate.php @@ -95,14 +95,15 @@ public function generate($namespace, $database, $poolName, $prefix, $include, $e $fields = $query->bindValue(':table', $table)->execute('show full columns from ' . $table)->getArray(); $this->parseFields($fields, $data, 'VIEW' === $item['TABLE_TYPE']); - if(true === $override || 'base' === $override) + $baseFileName = File::path($baseModelPath, $className . 'Base.php'); + if(!is_file($baseFileName) || true === $override || 'base' === $override) { echo 'Generating ', $table, ' BaseClass...', PHP_EOL; $baseContent = $this->renderTemplate('base-template', $data); - file_put_contents(File::path($baseModelPath, $className . 'Base.php'), $baseContent); + file_put_contents($baseFileName, $baseContent); } - if(true === $override || 'model' === $override) + if(!is_file($fileName) || true === $override || 'model' === $override) { echo 'Generating ', $table, ' Class...', PHP_EOL; $content = $this->renderTemplate('template', $data);