From 9a685e7a4839058a99ddcb5f9c79c126f5ce318b Mon Sep 17 00:00:00 2001 From: David M Date: Thu, 1 Feb 2007 03:13:08 +0000 Subject: [PATCH] - should fix some Firebird issues ( can't believe that nobody found this until now ) git-svn-id: file:///svn/phpbb/trunk@6954 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_database.php | 16 ++++++++-- phpBB/includes/acp/acp_icons.php | 12 ++++++- phpBB/includes/acp/acp_main.php | 12 ++++++- phpBB/includes/functions_admin.php | 12 ++++++- phpBB/includes/functions_convert.php | 12 ++++++- phpBB/includes/search/fulltext_native.php | 38 +++++++++++++++++++++-- phpBB/install/install_convert.php | 14 ++++++++- 7 files changed, 106 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index c5fadbfd0a..87c40ef78f 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -167,6 +167,7 @@ class acp_database // Get the table structure if ($structure) { + $sql_data .= "\n"; switch ($db->sql_layer) { case 'mysqli': @@ -213,7 +214,18 @@ class acp_database else { // We might wanna empty out all that junk :D - $sql_data .= (($db->sql_layer == 'sqlite') ? 'DELETE FROM ' : 'TRUNCATE TABLE ') . $table_name . ";\n"; + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $sql_data .= 'DELETE FROM '; + break; + + default: + $sql_data .= 'TRUNCATE TABLE '; + break; + } + $sql_data .= $table_name . ";\n"; } // Now write the data for the first time. :) @@ -757,7 +769,7 @@ class acp_database if ($retrieved_data) { - $sql_data = "\nGO\n"; + $sql_data = "GO\n"; if ($ident_set) { $sql_data .= "\nSET IDENTITY_INSERT $table_name OFF\nGO\n"; diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 321df3ecb1..bcdd8c71d8 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -334,7 +334,17 @@ class acp_icons // The user has already selected a smilies_pak file if ($current == 'delete') { - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . $table); + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . $table); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . $table); + break; + } switch ($mode) { diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index fad9ad47b7..bf958ba319 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -147,7 +147,17 @@ class acp_main break; case 'db_track': - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . TOPICS_POSTED_TABLE); + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); + break; + } // This can get really nasty... therefore we only do the last six months $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 8e4865fa97..7208aee113 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1983,7 +1983,17 @@ function cache_moderators() $cache->destroy('sql', MODERATOR_CACHE_TABLE); // Clear table - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . MODERATOR_CACHE_TABLE); + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE); + break; + } // We add moderators who have forum moderator permissions without an explicit ACL_NEVER setting $hold_ary = $ug_id_ary = $sql_ary = array(); diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 14dd4c370b..ab903ac2ad 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1833,7 +1833,17 @@ function update_topics_posted() { global $db, $config; - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . TOPICS_POSTED_TABLE); + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); + break; + } // This can get really nasty... therefore we only do the last six months $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60); diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 11ca09805a..bd197feede 100755 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -1266,9 +1266,41 @@ class fulltext_native extends search_backend { global $db; - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . SEARCH_WORDLIST_TABLE); - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . SEARCH_WORDMATCH_TABLE); - $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . SEARCH_RESULTS_TABLE); + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE); + break; + } + + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE); + break; + } + + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query('DELETE FROM ' . SEARCH_RESULTS_TABLE); + break; + + default: + $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); + break; + } } /** diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 256dd13b67..2b910f78a7 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -545,7 +545,19 @@ class install_convert extends module // Make some short variables accessible, for easier referencing $convert->convertor_tag = basename($convert->options['tag']); $convert->src_table_prefix = $convert->options['table_prefix']; - $convert->truncate_statement = ($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM '; + + + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $convert->truncate_statement = 'DELETE FROM '; + break; + + default: + $convert->truncate_statement = 'TRUNCATE TABLE '); + break; + } $get_info = false;