Ejemplo n.º 1
0
 private function writeConfig()
 {
     self::_appendLog('保存配置文件。。。');
     $dbHost = LuLu::getPostValue('dbHost');
     $dbName = LuLu::getPostValue('dbName');
     $dbUsername = LuLu::getPostValue('dbUsername');
     $dbPassword = LuLu::getPostValue('dbPassword');
     $tbPre = LuLu::getPostValue('tbPre');
     $dbConfig = ['class' => 'yii\\db\\Connection', 'dsn' => "mysql:host={$dbHost};dbname={$dbName}", 'username' => $dbUsername, 'password' => $dbPassword, 'charset' => 'utf8', 'tablePrefix' => $tbPre, 'enableSchemaCache' => true, 'schemaCache' => 'schemaCache'];
     try {
         FileHelper::writeArray(LuLu::getAlias('@data/config/db.php'), $dbConfig);
         self::_appendLog('配置文件保存成功');
         unset($dbConfig['class']);
         return $dbConfig;
     } catch (\Exception $e) {
         self::_appendLog('配置文件保存出错<br>' . $e->getMessage(), true);
         return false;
     }
 }