mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Nexus\Install;
|
|
|
|
class Update extends Install
|
|
{
|
|
|
|
protected $steps = ['环境检测', '添加 .env 文件', '修改&创建数据表', '导入数据'];
|
|
|
|
|
|
public function getLogFile()
|
|
{
|
|
return sprintf('%s/nexus_update_%s.log', sys_get_temp_dir(), date('Ymd'));
|
|
}
|
|
|
|
public function getUpdateDirectory()
|
|
{
|
|
return ROOT_PATH . 'public/update';
|
|
}
|
|
|
|
public function listTableFieldsFromCreateTable($createTableSql)
|
|
{
|
|
$arr = preg_split("/[\r\n]+/", $createTableSql);
|
|
$result = [];
|
|
foreach ($arr as $value) {
|
|
$value = trim($value);
|
|
if (substr($value, 0, 1) != '`') {
|
|
continue;
|
|
}
|
|
$pos = strpos($value, '`', 1);
|
|
$field = substr($value, 1, $pos - 1);
|
|
$result[$field] = rtrim($value, ',');
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function listTableFieldsFromDb($table)
|
|
{
|
|
$sql = "desc $table";
|
|
$res = sql_query($sql);
|
|
$data = [];
|
|
while ($row = mysql_fetch_assoc($res)) {
|
|
$data[$row['Field']] = $row;
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
} |