mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 22:38:52 +00:00
- SQLite handling in custom profiles
- Removed an extra ';' - Install works with SQLite again git-svn-id: file:///svn/phpbb/trunk@6082 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
10846d462a
commit
751a154af0
4 changed files with 99 additions and 16 deletions
|
@ -105,7 +105,51 @@ class acp_profile
|
||||||
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id");
|
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id");
|
||||||
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
|
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
|
||||||
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
|
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
|
||||||
$db->sql_query('ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " DROP $field_ident");
|
|
||||||
|
switch (SQL_LAYER)
|
||||||
|
{
|
||||||
|
case 'sqlite':
|
||||||
|
$sql = "SELECT sql
|
||||||
|
FROM sqlite_master
|
||||||
|
WHERE type = 'table'
|
||||||
|
AND name = '" . PROFILE_FIELDS_DATA_TABLE . "'
|
||||||
|
ORDER BY type DESC, name;";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Create a temp table and populate it, destroy the existing one
|
||||||
|
$db->sql_query(preg_replace('#CREATE\s+TABLE\s+' . PROFILE_FIELDS_DATA_TABLE . '#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql']));
|
||||||
|
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE);
|
||||||
|
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE);
|
||||||
|
|
||||||
|
preg_match('#\((.*)\)#s', $row['sql'], $matches);
|
||||||
|
|
||||||
|
$new_table_cols = $matches[1];
|
||||||
|
$old_table_cols = explode(',', $new_table_cols);
|
||||||
|
$column_list = array();
|
||||||
|
foreach($old_table_cols as $declaration)
|
||||||
|
{
|
||||||
|
$entities = preg_split('#\s+#', $declaration);
|
||||||
|
if ($entities[0] !== $field_ident)
|
||||||
|
{
|
||||||
|
$column_list[] = $entities[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = implode(',', $column_list);
|
||||||
|
|
||||||
|
$new_table_cols = preg_replace('/' . $field_ident . '[^,]+,/', '', $new_table_cols);
|
||||||
|
|
||||||
|
// create a new table and fill it up. destroy the temp one
|
||||||
|
$db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');');
|
||||||
|
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;');
|
||||||
|
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp');
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$db->sql_query('ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " DROP $field_ident");
|
||||||
|
}
|
||||||
|
|
||||||
$order = 0;
|
$order = 0;
|
||||||
|
|
||||||
|
@ -937,38 +981,78 @@ class acp_profile
|
||||||
|
|
||||||
case 'sqlite':
|
case 'sqlite':
|
||||||
|
|
||||||
// We are defining the biggest common value, because of the possibility to edit the min/max values of each field.
|
|
||||||
$sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD $field_ident ";
|
|
||||||
|
|
||||||
switch ($field_type)
|
switch ($field_type)
|
||||||
{
|
{
|
||||||
case FIELD_STRING:
|
case FIELD_STRING:
|
||||||
$sql .= ' VARCHAR(255) ';
|
$type = ' VARCHAR(255) ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIELD_DATE:
|
case FIELD_DATE:
|
||||||
$sql .= 'VARCHAR(10) ';
|
$type = 'VARCHAR(10) ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIELD_TEXT:
|
case FIELD_TEXT:
|
||||||
$sql .= "TEXT(65535)";
|
$type = "TEXT(65535)";
|
||||||
// ADD {$field_ident}_bbcode_uid VARCHAR(5) NOT NULL,
|
// ADD {$field_ident}_bbcode_uid VARCHAR(5) NOT NULL,
|
||||||
// ADD {$field_ident}_bbcode_bitfield INT(11) UNSIGNED";
|
// ADD {$field_ident}_bbcode_bitfield INT(11) UNSIGNED";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIELD_BOOL:
|
case FIELD_BOOL:
|
||||||
$sql .= 'TINYINT(2) ';
|
$type = 'TINYINT(2) ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIELD_DROPDOWN:
|
case FIELD_DROPDOWN:
|
||||||
$sql .= 'MEDIUMINT(8) ';
|
$type = 'MEDIUMINT(8) ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIELD_INT:
|
case FIELD_INT:
|
||||||
$sql .= 'BIGINT(20) ';
|
$type = 'BIGINT(20) ';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We are defining the biggest common value, because of the possibility to edit the min/max values of each field.
|
||||||
|
if (version_compare(sqlite_libversion(), '3.0') == -1)
|
||||||
|
{
|
||||||
|
$sql = "SELECT sql
|
||||||
|
FROM sqlite_master
|
||||||
|
WHERE type = 'table'
|
||||||
|
AND name = '" . PROFILE_FIELDS_DATA_TABLE . "'
|
||||||
|
ORDER BY type DESC, name;";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Create a temp table and populate it, destroy the existing one
|
||||||
|
$db->sql_query(preg_replace('#CREATE\s+TABLE\s+' . PROFILE_FIELDS_DATA_TABLE . '#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql']));
|
||||||
|
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE);
|
||||||
|
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE);
|
||||||
|
|
||||||
|
preg_match('#\((.*)\)#s', $row['sql'], $matches);
|
||||||
|
|
||||||
|
$new_table_cols = $matches[1];
|
||||||
|
$old_table_cols = explode(',', $new_table_cols);
|
||||||
|
$column_list = array();
|
||||||
|
foreach($old_table_cols as $declaration)
|
||||||
|
{
|
||||||
|
$entities = preg_split('#\s+#', $declaration);
|
||||||
|
$column_list[] = $entities[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = implode(',', $column_list);
|
||||||
|
|
||||||
|
$new_table_cols = $field_ident . ' ' . $type . ',' . $new_table_cols;
|
||||||
|
|
||||||
|
// create a new table and fill it up. destroy the temp one
|
||||||
|
$db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');');
|
||||||
|
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;');
|
||||||
|
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD $field_ident $type";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mssql':
|
case 'mssql':
|
||||||
|
|
|
@ -41,7 +41,7 @@ class dbal_sqlite extends dbal
|
||||||
$this->dbname = $database;
|
$this->dbname = $database;
|
||||||
|
|
||||||
$error = '';
|
$error = '';
|
||||||
$this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error);;
|
$this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error);
|
||||||
|
|
||||||
if ($this->db_connect_id)
|
if ($this->db_connect_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -391,7 +391,7 @@ class install_install extends module
|
||||||
{
|
{
|
||||||
if (!$this->can_load_dll($this->available_dbms[$dbms]['MODULE']))
|
if (!$this->can_load_dll($this->available_dbms[$dbms]['MODULE']))
|
||||||
{
|
{
|
||||||
$error['db'][] = $lang['INST_ERR_NO_DB'];;
|
$error['db'][] = $lang['INST_ERR_NO_DB'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ class install_install extends module
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test against the default password rules
|
// Test against the default password rules
|
||||||
if ($admin_pass1 != '' && strlen($admin_pass1) < 6)
|
if ($admin_pass1 != '' && strlen($admin_pass1) < 4)
|
||||||
{
|
{
|
||||||
$error[] = $lang['INST_ERR_PASSWORD_TOO_SHORT'];
|
$error[] = $lang['INST_ERR_PASSWORD_TOO_SHORT'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -621,9 +621,8 @@ CREATE TABLE phpbb_search_results (
|
||||||
# Table: phpbb_search_wordlist
|
# Table: phpbb_search_wordlist
|
||||||
CREATE TABLE phpbb_search_wordlist (
|
CREATE TABLE phpbb_search_wordlist (
|
||||||
word_text varchar(252) NOT NULL DEFAULT '',
|
word_text varchar(252) NOT NULL DEFAULT '',
|
||||||
word_id mediumint(8) NOT NULL,
|
word_id INTEGER PRIMARY KEY NOT NULL,
|
||||||
word_common tinyint(1) NOT NULL DEFAULT '0',
|
word_common tinyint(1) NOT NULL DEFAULT '0'
|
||||||
PRIMARY KEY (word_text)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX phpbb_search_wordlist_word_id on phpbb_search_wordlist (word_id);
|
CREATE INDEX phpbb_search_wordlist_word_id on phpbb_search_wordlist (word_id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue