mysql 版本检测
This commit is contained in:
parent
f8db5ebf18
commit
a7f55ba1cb
|
|
@ -103,7 +103,7 @@ class EnvironmentController extends Controller
|
|||
* Validate database connection with user credentials (Form Wizard).
|
||||
*
|
||||
* @param Request $request
|
||||
* @return bool
|
||||
* @return array|bool
|
||||
*/
|
||||
private function checkDatabaseConnection(Request $request)
|
||||
{
|
||||
|
|
@ -132,12 +132,16 @@ class EnvironmentController extends Controller
|
|||
|
||||
DB::purge();
|
||||
|
||||
$result = [];
|
||||
try {
|
||||
DB::connection()->getPdo();
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$serverVersion = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
|
||||
if (version_compare($serverVersion, '5.7', '>=')) {
|
||||
$result['database_version'] = trans('installer::installer_messages.environment.db_connection_failed_invalid_version');
|
||||
return $result;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$result = [];
|
||||
} catch (\PDOException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 2002:
|
||||
$result['database_hostname'] = trans('installer::installer_messages.environment.db_connection_failed_host_port');
|
||||
|
|
@ -151,9 +155,8 @@ class EnvironmentController extends Controller
|
|||
$result['database_name'] = trans('installer::installer_messages.environment.db_connection_failed_database_name');
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ return [
|
|||
'db_connection_failed_host_port' => 'Database host or port error!',
|
||||
'db_connection_failed_user_password' => 'Database username or password error!',
|
||||
'db_connection_failed_database_name' => 'Database name not exist!',
|
||||
'db_connection_failed_invalid_version' => 'MySQL version must grater than 5.7!',
|
||||
'app_environment_label_local' => 'Local',
|
||||
'app_environment_label_developement' => 'Development',
|
||||
'app_environment_label_qa' => 'Qa',
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ return [
|
|||
'db_connection_failed_host_port' => '数据库主机或端口错误!',
|
||||
'db_connection_failed_user_password' => '数据库账号或密码错误!',
|
||||
'db_connection_failed_database_name' => '数据库名不存在!',
|
||||
'db_connection_failed_invalid_version' => '数据库版本必须大于5.7!',
|
||||
'db_connection_label_mysql' => 'MySQL',
|
||||
'db_connection_label_sqlite' => 'SQLite',
|
||||
'db_connection_label_pgsql' => 'PostgreSQL',
|
||||
|
|
|
|||
Loading…
Reference in New Issue