切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
幻灵姬风
7 years ago
提交者
Karson
7 years ago
提交
d54583e9468fa32c9f95de4520704707a8ac9b0b
2 个父辈
3920be0f
03f6ba62
!66 修复执行install命令主机不是127.0.0.1的时候安装失败问题
Merge pull request !66 from 小埋酱/master
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
15 行增加
和
7 行删除
application/admin/command/Install.php
application/admin/command/Install.php
查看文件 @
d54583e
...
...
@@ -43,8 +43,7 @@ class Install extends Command
$password
=
$input
->
getOption
(
'password'
);
$installLockFile
=
__DIR__
.
"/Install/install.lock"
;
if
(
is_file
(
$installLockFile
)
&&
!
$force
)
{
if
(
is_file
(
$installLockFile
)
&&
!
$force
)
{
throw
new
Exception
(
"
\n
FastAdmin already installed!
\n
If you need to reinstall again, use the parameter --force=true "
);
}
...
...
@@ -58,21 +57,30 @@ class Install extends Command
$pdo
->
setAttribute
(
PDO
::
ATTR_ERRMODE
,
PDO
::
ERRMODE_EXCEPTION
);
$pdo
->
query
(
"CREATE DATABASE IF NOT EXISTS `
{
$database
}
` CHARACTER SET utf8 COLLATE utf8_general_ci;"
);
// 连接install命令中指定的数据库
$instance
=
Db
::
connect
([
'type'
=>
"
{
$config
[
'type'
]}
",
'hostname' => "
{
$hostname
}
"
,
'hostport'
=>
"
{
$hostport
}
"
,
'database'
=>
"
{
$database
}
"
,
'username'
=>
"
{
$username
}
"
,
'password'
=>
"
{
$password
}
"
,
]);
// 查询一次SQL,判断连接是否正常
Db
::
execute
(
"SELECT 1"
);
$instance
->
execute
(
"SELECT 1"
);
// 调用原生PDO对象进行批量查询
Db
::
getPdo
()
->
exec
(
$sql
);
$instance
->
getPdo
()
->
exec
(
$sql
);
file_put_contents
(
$installLockFile
,
1
);
$dbConfigFile
=
APP_PATH
.
'database.php'
;
$config
=
@
file_get_contents
(
$dbConfigFile
);
$callback
=
function
(
$matches
)
use
(
$hostname
,
$hostport
,
$username
,
$password
,
$database
,
$prefix
)
{
$callback
=
function
(
$matches
)
use
(
$hostname
,
$hostport
,
$username
,
$password
,
$database
,
$prefix
)
{
$field
=
$matches
[
1
];
$replace
=
$$field
;
if
(
$matches
[
1
]
==
'hostport'
&&
$hostport
==
3306
)
{
if
(
$matches
[
1
]
==
'hostport'
&&
$hostport
==
3306
)
{
$replace
=
''
;
}
return
"'
{
$matches
[
1
]}
'{$matches[2]}=>{$matches[3]}Env::get('
database
.
{
$matches
[
1
]}
', '
{
$replace
}
'),"
;
...
...
请
注册
或
登录
后发表评论