aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-07-03 00:21:40 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-07-03 00:21:40 +0000
commit662e12d466ef95a8d0c90869e5009a92ce197756 (patch)
tree6abe6004321d6aaba6bef8383aa446af6220dae4 /phpBB
parent98fc394eb350d55c1876ffe8ce02260113af1368 (diff)
downloadforums-662e12d466ef95a8d0c90869e5009a92ce197756.tar
forums-662e12d466ef95a8d0c90869e5009a92ce197756.tar.gz
forums-662e12d466ef95a8d0c90869e5009a92ce197756.tar.bz2
forums-662e12d466ef95a8d0c90869e5009a92ce197756.tar.xz
forums-662e12d466ef95a8d0c90869e5009a92ce197756.zip
- Dramatic speed-up in SQLite backup code
- Wrote *another* patch around SQLite - SQLite has a lack of (among other things) solid definition of their tables. e.g. "foo" and foo are both valid col names... Database backup and profile creation are now both aware of such "features" meh, i hope this all works... git-svn-id: file:///svn/phpbb/trunk@6140 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/acp/acp_database.php41
-rw-r--r--phpBB/includes/acp/acp_profile.php9
2 files changed, 42 insertions, 8 deletions
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index 5d023d6205..1429719df2 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -361,13 +361,48 @@ class acp_database
break;
case 'sqlite':
+ // This is *not* my fault. The PHP guys forgot a call to finalize when they wrote this function. This forces all the tables to stay locked...
+ // They finally fixed it in 5.3 but 5.2 still have this so instead, we go and grab the column types by smashing open the sqlite_master table
+ // and grope around for things that remind us of datatypes...
+ if (version_compare(phpversion(), '5.3', '>='))
+ {
+ $col_types = sqlite_fetch_column_types($table_name, $db->db_connect_id);
+ }
+ else
+ {
+ $sql = "SELECT sql
+ FROM sqlite_master
+ WHERE type = 'table'
+ AND name = '" . $table_name . "'";
+ $table_data = sqlite_single_query($db->db_connect_id, $sql);
+ $table_data = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', '', $table_data);
+ $table_data = trim($table_data);
+
+ preg_match('#\((.*)\)#s', $table_data, $matches);
+
+ $column_list = array();
+ $table_cols = explode(',', trim($matches[1]));
+ foreach($table_cols as $declaration)
+ {
+ $entities = preg_split('#\s+#', trim($declaration));
+ $column_name = preg_replace('/"?([^"]+)"?/', '\1', $entities[0]);
+
+ // Hit a primary key, those are not what we need :D
+ if (empty($entities[1]))
+ {
+ continue;
+ }
+ $col_types[$column_name] = $entities[1];
+ }
+ }
- $col_types = sqlite_fetch_column_types($table_name, $db->db_connect_id);
+ // Unbueffered query and the foreach make this ultra fast, we wait for nothing.
$sql = "SELECT *
FROM $table_name";
- $result = $db->sql_query($sql);
+ $result = sqlite_unbuffered_query($sql, $db->db_connect_id);
+ $rows = sqlite_fetch_all($result, SQLITE_ASSOC);
- while ($row = $db->sql_fetchrow($result))
+ foreach ($rows as $row)
{
$names = $data = array();
foreach ($row as $row_name => $row_data)
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 738eda5101..1ada445770 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -119,7 +119,7 @@ class acp_profile
$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(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);
@@ -130,7 +130,7 @@ class acp_profile
$column_list = array();
foreach($old_table_cols as $declaration)
{
- $entities = preg_split('#\s+#', $declaration);
+ $entities = preg_split('#\s+#', trim($declaration));
if ($entities[0] !== $field_ident)
{
$column_list[] = $entities[0];
@@ -1023,7 +1023,7 @@ class acp_profile
$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(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);
@@ -1034,8 +1034,7 @@ class acp_profile
$column_list = array();
foreach($old_table_cols as $declaration)
{
- $entities = preg_split('#\s+#', $declaration);
- var_dump($entities);
+ $entities = preg_split('#\s+#', trim($declaration));
$column_list[] = $entities[0];
}