Skip to content

Commit

Permalink
系统安装,设置mysql部分,加入mysql 端口号
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Dec 4, 2019
1 parent ef792f6 commit ffc60b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ public function updateDatabaseConfig($editForm)
$host = $editForm['host'];
$database = $editForm['database'];
$user = $editForm['user'];
$port = $editForm['port'];
if (!$port) {
$port = '3306';
}
$password = $editForm['password'];
$dbConfig = [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host='.$host.';dbname='.$database,
'dsn' => 'mysql:host='.$host.';port='.$port.';dbname='.$database,
'username' => $user,
'password' => $password,
'charset' => 'utf8',
Expand Down Expand Up @@ -162,6 +166,7 @@ public function updateDatabaseConfig($editForm)
//$mainLocalInfo = require($mainLocalFile);
// 进行文件替换
$mainLocalInfo = str_replace('{mysql_host}', $host, $mainLocalInfo);
$mainLocalInfo = str_replace('{mysql_port}', $port, $mainLocalInfo);
$mainLocalInfo = str_replace('{mysql_database}', $database, $mainLocalInfo);
$mainLocalInfo = str_replace('{mysql_user}', $user, $mainLocalInfo);
$mainLocalInfo = str_replace('{mysql_password}', $password, $mainLocalInfo);
Expand Down
5 changes: 5 additions & 0 deletions app/appinstall/modules/Database/views/config/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<input type="text" class="form-control" value="<?= $editForm['host'] ?>" name="editForm[host]" placeholder="Mysql数据库Host Ip,本地请填写127.0.0.1">
</div>

<div class="form-group">
<label for="name">Mysql数据库端口</label>
<input type="text" class="form-control" value="<?= $editForm['port'] ? $editForm['port'] : '3306' ?>" name="editForm[port]" placeholder="Mysql数据库port,请先去mysql中创建数据库,然后再填写">
</div>

<div class="form-group">
<label for="name">Mysql数据库名称</label>
<input type="text" class="form-control" value="<?= $editForm['database'] ?>" name="editForm[database]" placeholder="Mysql数据库名称,请先去mysql中创建数据库,然后再填写">
Expand Down

0 comments on commit ffc60b8

Please sign in to comment.