Skip to content

Commit

Permalink
修复生成模型时-override指定为非bool值,可能有文件没生成的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Feb 19, 2019
1 parent 0c7d962 commit 0bd4fe2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Tool/Tools/Generate/Model/ModelGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0bd4fe2

Please sign in to comment.