From 055fe9e82dc15c84dbdad866e8a486397d32cfe9 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Fri, 4 Jul 2003 17:19:00 +0000 Subject: [PATCH] sqlite support UNION ALL SELECT method git-svn-id: file:///svn/phpbb/trunk@4203 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_ban.php | 5 +-- phpBB/adm/admin_groups.php | 27 ++++++--------- phpBB/adm/admin_permissions.php | 2 +- phpBB/adm/admin_search.php | 15 +++++--- phpBB/includes/functions.php | 9 +++-- phpBB/includes/message_parser.php | 57 +++++++++++++++---------------- 6 files changed, 59 insertions(+), 56 deletions(-) diff --git a/phpBB/adm/admin_ban.php b/phpBB/adm/admin_ban.php index 7299e20b1c..efed0370c9 100644 --- a/phpBB/adm/admin_ban.php +++ b/phpBB/adm/admin_ban.php @@ -257,11 +257,12 @@ if (isset($_REQUEST['bansubmit'])) break; case 'mssql': + case 'sqlite': $sql .= (($sql != '') ? ' UNION ALL ' : '') . " SELECT $ban_entry, $current_time, $ban_end, $ban_exclude, '$ban_reason'"; break; default: - $sql = "INSERT INTO " . BANLIST_TABLE . " ($type, ban_start, ban_end, ban_exclude, ban_reason) + $sql = 'INSERT INTO ' . BANLIST_TABLE . " ($type, ban_start, ban_end, ban_exclude, ban_reason) VALUES ($ban_entryx, $current_time, $ban_end, $ban_exclude, '$ban_reason')"; $db->sql_query($sql); $sql = ''; @@ -270,7 +271,7 @@ if (isset($_REQUEST['bansubmit'])) if ($sql != '') { - $sql = "INSERT INTO " . BANLIST_TABLE . " ($type, ban_start, ban_end, ban_exclude, ban_reason) + $sql = 'INSERT INTO ' . BANLIST_TABLE . " ($type, ban_start, ban_end, ban_exclude, ban_reason) VALUES $sql"; $db->sql_query($sql); } diff --git a/phpBB/adm/admin_groups.php b/phpBB/adm/admin_groups.php index e0ebf48c30..5804f332d3 100644 --- a/phpBB/adm/admin_groups.php +++ b/phpBB/adm/admin_groups.php @@ -434,20 +434,6 @@ function swatch() // Insert the new users switch (SQL_LAYER) { - case 'postgresql': - case 'msaccess': - case 'mssql-odbc': - case 'oracle': - case 'db2': - foreach ($user_id_ary as $user_id) - { - $sql = "INSERT INTO $table_sql (user_id, group_id) - VALUES ($user_id, $group_id)"; - $db->sql_query($sql); - } - - break; - case 'mysql': case 'mysql4': $sql = "INSERT INTO $table_sql (user_id, group_id) @@ -456,10 +442,19 @@ function swatch() break; case 'mssql': - $sql = "INSERT INTO $table_sql (user_id, group_id) - VALUES " . implode(' UNION ALL ', preg_replace('#^([0-9]+)$#', "(\\1, $group_id)", $user_id_ary)); + case 'sqlite': + $sql = "INSERT INTO $table_sql (user_id, group_id) " . implode(' UNION ALL ', preg_replace('#^([0-9]+)$#', "(\\1, $group_id)", $user_id_ary)); $db->sql_query($sql); break; + + default: + foreach ($user_id_ary as $user_id) + { + $sql = "INSERT INTO $table_sql (user_id, group_id) + VALUES ($user_id, $group_id)"; + $db->sql_query($sql); + } + break; } // Update user settings (color, rank) if applicable diff --git a/phpBB/adm/admin_permissions.php b/phpBB/adm/admin_permissions.php index 2ad92446b4..de5da65bef 100644 --- a/phpBB/adm/admin_permissions.php +++ b/phpBB/adm/admin_permissions.php @@ -3,7 +3,7 @@ * admin_permissions.php * ------------------- * begin : Saturday, Feb 13, 2001 - * copyright : (C) 2001 The phpBB Group + * copyright : © 2001 The phpBB Group * email : support@phpbb.com * * $Id$ diff --git a/phpBB/adm/admin_search.php b/phpBB/adm/admin_search.php index 69b427caa3..32cabc8dcd 100644 --- a/phpBB/adm/admin_search.php +++ b/phpBB/adm/admin_search.php @@ -201,13 +201,16 @@ if (isset($_POST['start']) || isset($_GET['batchstart'])) { case 'mysql': case 'mysql4': - $value_sql .= (($value_sql != '') ? ', ' : '') . '(\'' . $word[$i] . '\')'; + $value_sql .= (($value_sql != '') ? ', ' : '') . "('" . $word[$i] . "')"; break; + case 'mssql': + case 'sqlite': $value_sql .= (($value_sql != '') ? ' UNION ALL ' : '') . "SELECT '" . $word[$i] . "'"; break; + default: - $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) + $sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . " (word_text) VALUES ('" . $word[$i] . "')"; $db->sql_query($sql); break; @@ -221,11 +224,13 @@ if (isset($_POST['start']) || isset($_GET['batchstart'])) { case 'mysql': case 'mysql4': - $sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text) + $sql = 'INSERT IGNORE INTO ' . SEARCH_WORD_TABLE . " (word_text) VALUES $value_sql"; break; + case 'mssql': - $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) + case 'sqlite': + $sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . " (word_text) $value_sql"; break; } @@ -240,7 +245,7 @@ if (isset($_POST['start']) || isset($_GET['batchstart'])) if ($match_sql != '') { - $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) + $sql = 'INSERT INTO ' . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) SELECT $post_id, word_id, $title_match FROM " . SEARCH_WORD_TABLE . " WHERE word_text IN ($match_sql)"; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9a0dbd94b0..092b5b592a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -557,9 +557,11 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) case 'mysql': case 'mysql4': $sql .= (($sql != '') ? ', ' : '') . '(' . $user->data['user_id'] . ', ' . $row['forum_id'] . ", $current_time)"; + $sql = 'VALUES ' . $sql; break; case 'mssql': + case 'sqlite': $sql = (($sql != '') ? ' UNION ALL ' : '') . ' SELECT ' . $user->data['user_id'] . ', ' . $row['forum_id'] . ", $current_time"; break; @@ -572,8 +574,7 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) if ($sql != '') { - $sql = 'INSERT INTO ' . FORUMS_TRACK_TABLE . ' (user_id, forum_id, mark_time) - VALUES ' . $sql; + $sql = 'INSERT INTO ' . FORUMS_TRACK_TABLE . " (user_id, forum_id, mark_time) $sql"; $db->sql_query($sql); } } @@ -941,6 +942,10 @@ function login_box($s_action, $s_hidden_fields = '', $login_explain = '') $err = ($result === 0) ? $user->lang['ACTIVE_ERROR'] : $user->lang['LOGIN_ERROR']; } + $sql = 'DELETE FROM ' . CONFIRM_TABLE . ' + WHERE confirm_time < ' . (time() - $config['session_length']); +// $db->sql_query($sql); + $template->assign_vars(array( 'LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $login_explain, diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 63c8e266d5..bea859b6f6 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -286,7 +286,7 @@ class parse_message $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string'); foreach ($conf as $ini_var) { - ini_set($ini_var, str_replace('highlight.', 'hl_', $ini_var)); + ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var)); } ob_start(); @@ -294,16 +294,16 @@ class parse_message $code = ob_get_contents(); ob_end_clean(); - $str_from = array('', '', '', '[', ']', '.'); + $str_from = array('', '', '', '[', ']', '.'); if ($remove_tags) { - $str_from[] = '<?php '; + $str_from[] = '<?php '; $str_to[] = ''; - $str_from[] = '<?php '; - $str_to[] = ''; - $str_from[] = '?>'; + $str_from[] = '<?php '; + $str_to[] = ''; + $str_from[] = '?>'; $str_to[] = ''; } @@ -929,9 +929,9 @@ class fulltext_search $words = array(); if ($mode == 'edit') { - $sql = "SELECT w.word_id, w.word_text, m.title_match - FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m - WHERE m.post_id = " . intval($post_id) . " + $sql = 'SELECT w.word_id, w.word_text, m.title_match + FROM ' . SEARCH_WORD_TABLE . ' w, ' . SEARCH_MATCH_TABLE . " m + WHERE m.post_id = $post_id AND w.word_id = m.word_id"; $result = $db->sql_query($sql); @@ -967,9 +967,9 @@ class fulltext_search // and then add (or remove) matches between the words and this post if (sizeof($unique_add_words)) { - $sql = "SELECT word_id, word_text - FROM " . SEARCH_WORD_TABLE . " - WHERE word_text IN (" . implode(', ', preg_replace('#^(.*)$#', '\'\1\'', $unique_add_words)) . ")"; + $sql = 'SELECT word_id, word_text + FROM ' . SEARCH_WORD_TABLE . ' + WHERE word_text IN (' . implode(', ', preg_replace('#^(.*)$#', '\'\1\'', $unique_add_words)) . ")"; $result = $db->sql_query($sql); $word_ids = array(); @@ -986,30 +986,27 @@ class fulltext_search { switch (SQL_LAYER) { - case 'postgresql': - case 'msaccess': - case 'mssql-odbc': - case 'oracle': - case 'db2': - foreach ($new_words as $word) - { - $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) - VALUES ('" . $word . "')"; - $db->sql_query($sql); - } - - break; case 'mysql': case 'mysql4': - $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) - VALUES " . implode(', ', preg_replace('#^(.*)$#', '(\'\1\')', $new_words)); + $sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . ' (word_text) + VALUES ' . implode(', ', preg_replace('#^(.*)$#', '(\'\1\')', $new_words)); $db->sql_query($sql); break; + case 'mssql': - $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) - VALUES " . implode(' UNION ALL ', preg_replace('#^(.*)$#', 'SELECT \'\1\'', $new_words)); + case 'sqlite': + $sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . ' (word_text) ' . implode(' UNION ALL ', preg_replace('#^(.*)$#', "SELECT '\\1'", $new_words)); $db->sql_query($sql); break; + + default: + foreach ($new_words as $word) + { + $sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . " (word_text) + VALUES ('$word')"; + $db->sql_query($sql); + } + break; } } unset($new_words);