From 6992cc2c73cc30cf02e9d93aad2946118d80c859 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 15 Nov 2013 08:44:59 -0500 Subject: [PATCH] Fixes #1196. --- extensions/gii/generators/model/Generator.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/gii/generators/model/Generator.php b/extensions/gii/generators/model/Generator.php index 32ba2e5..ea43f6b 100644 --- a/extensions/gii/generators/model/Generator.php +++ b/extensions/gii/generators/model/Generator.php @@ -115,11 +115,16 @@ class Generator extends \yii\gii\Generator */ public function autoCompleteData() { - return [ - 'tableName' => function () { - return $this->getDbConnection()->getSchema()->getTableNames(); - }, - ]; + $db = $this->getDbConnection(); + if ($db === null) { + return [ + 'tableName' => function () use ($db) { + return $db->getSchema()->getTableNames(); + }, + ]; + } else { + return []; + } } /**