From 34582524ba39e895e072129b1c83e48d94864cff Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Thu, 26 Apr 2012 19:18:17 +0200 Subject: adapted admin section for FAQ to new database scheme --- db/update.d/01_faq.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'db/update.d/01_faq.php') diff --git a/db/update.d/01_faq.php b/db/update.d/01_faq.php index 1e32f1ad..759cc109 100644 --- a/db/update.d/01_faq.php +++ b/db/update.d/01_faq.php @@ -1,16 +1,20 @@ ', $row['Frage'], 2); - $answer = explode('
', $row['Antwort'], 2); + $question = preg_split('#(?:<|<)br(?:>|>)#i', $row['Frage'], 2, PREG_SPLIT_NO_EMPTY); + $answer = preg_split('#(?:<|<)br(?:>|>)#i', $row['Antwort'], 2, PREG_SPLIT_NO_EMPTY); if(count($question) == 2 && count($answer) == 2) - sql_query("INSERT INTO `FAQ` (`Frage`, `Antwort`, `Sprache`) VALUES ('" . sql_escape(trim($question[1])) . "', '" . sql_escape(trim($answer[1])) . "', 'en')"); - sql_query("UPDATE `FAQ` SET `Frage` = '" . sql_escape(trim($question[0])) . "', `Antwort` = '" . sql_escape(trim($answer[0])) . "', `Sprache` = 'de' WHERE `FID` = " . $row['FID']); + sql_query("INSERT INTO `FAQ` (`Frage`, `Antwort`, `Sprache`, `QID`) VALUES ('" . sql_escape(trim($question[1])) . "', '" . sql_escape(trim($answer[1])) . "', 'en', $i)"); + sql_query("UPDATE `FAQ` SET `Frage` = '" . sql_escape(trim($question[0])) . "', `Antwort` = '" . sql_escape(trim($answer[0])) . "', `Sprache` = 'de', `QID` = $i WHERE `FID` = " . $row['FID']); + $i++; } + _add_index('FAQ', array('QID', 'Sprache'), 'UNIQUE'); $applied = true; } -- cgit v1.2.3-70-g09d2