Update Admin\Install page
Add dsn for PostgreSQL. Update prefix reserved. Change the check for the existence of the users table, because in PostgreSQL a query error aborts the execution of queries in this transaction.
This commit is contained in:
parent
04bdb5c23b
commit
66aff84a88
3 changed files with 18 additions and 14 deletions
|
@ -457,8 +457,8 @@ class Install extends Admin
|
|||
if (! \preg_match('%^[a-z][a-z\d_]*$%i', $prefix)) {
|
||||
$v->addError('Table prefix error');
|
||||
} elseif (
|
||||
'sqlite' === $v->dbtype
|
||||
&& 'sqlite_' === \strtolower($prefix)
|
||||
'sqlite_' === \strtolower($prefix)
|
||||
|| 'pg_' === \strtolower($prefix)
|
||||
) {
|
||||
$v->addError('Prefix reserved');
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ class Install extends Admin
|
|||
{
|
||||
$this->c->DB_USERNAME = $v->dbuser;
|
||||
$this->c->DB_PASSWORD = $v->dbpass;
|
||||
$this->c->DB_PREFIX = \is_string($v->dbprefix) ? $v->dbprefix : '';
|
||||
$this->c->DB_PREFIX = $v->dbprefix;
|
||||
$dbtype = $v->dbtype;
|
||||
$dbname = $v->dbname;
|
||||
|
||||
|
@ -502,6 +502,16 @@ class Install extends Admin
|
|||
case 'sqlite':
|
||||
break;
|
||||
case 'pgsql':
|
||||
if (\preg_match('%^([^:]+):(\d+)$%', $dbhost, $matches)) {
|
||||
$host = $matches[1];
|
||||
$port = $matches[2];
|
||||
} else {
|
||||
$host = $dbhost;
|
||||
$port = '5432';
|
||||
}
|
||||
|
||||
$this->c->DB_DSN = "pgsql:host={$host} port={$port} dbname={$dbname} options='--client_encoding=UTF8'";
|
||||
|
||||
break;
|
||||
default:
|
||||
//????
|
||||
|
@ -520,16 +530,10 @@ class Install extends Admin
|
|||
}
|
||||
|
||||
// проверка наличия таблицы пользователей в БД
|
||||
try {
|
||||
$stmt = $this->c->DB->query('SELECT 1 FROM ::users LIMIT 1');
|
||||
if ($this->c->DB->tableExists('users')) {
|
||||
$v->addError(['Existing table error', $v->dbprefix, $v->dbname]);
|
||||
|
||||
if (! empty($stmt->fetch())) {
|
||||
$v->addError(['Existing table error', $v->dbprefix, $v->dbname]);
|
||||
|
||||
return $dbhost;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// все отлично, таблица пользователей не найдена
|
||||
return $dbhost;
|
||||
}
|
||||
|
||||
// база MySQL, кодировка базы отличается от UTF-8 (4 байта)
|
||||
|
|
|
@ -151,7 +151,7 @@ msgid "Table prefix error"
|
|||
msgstr "The table prefix '%s' does not match the format."
|
||||
|
||||
msgid "Prefix reserved"
|
||||
msgstr "The table prefix 'sqlite_' is reserved for use by the SQLite engine."
|
||||
msgstr "The 'sqlite_' and 'pg_' prefixes are reserved. Please choose a different prefix."
|
||||
|
||||
msgid "Existing table error"
|
||||
msgstr "A table called '%1$susers' is already present in the database '%2$s'. This could mean that ForkBB is already installed or that another piece of software is installed and is occupying one or more of the table names ForkBB requires. If you want to install multiple copies of ForkBB in the same database, you must choose a different table prefix."
|
||||
|
|
|
@ -151,7 +151,7 @@ msgid "Table prefix error"
|
|||
msgstr "Префикс '%s' не соответсвует формату."
|
||||
|
||||
msgid "Prefix reserved"
|
||||
msgstr "Префикс 'sqlite_' зарезрвирован для SQLite."
|
||||
msgstr "Префиксы 'sqlite_' и 'pg_' зарезервированы. Выберите другой префикс."
|
||||
|
||||
msgid "Existing table error"
|
||||
msgstr "Таблица '%1$susers' уже существует в базе '%2$s'. Это может означать, что ForkBB был установлен в данную базу или другой программный пакет занимает таблицы, требуемые для работы ForkBB. Если вы хотите установить несколько копий форума в одну базу, выбирайте разные префиксы для них."
|
||||
|
|
Loading…
Add table
Reference in a new issue