diff options
author | Jan-Philipp Litza <jplitza@sylar.(none)> | 2011-12-26 16:04:54 +0100 |
---|---|---|
committer | Jan-Philipp Litza <jplitza@sylar.(none)> | 2011-12-26 16:04:54 +0100 |
commit | 7154097581f231753005aaabdc12d00173b7ce27 (patch) | |
tree | 2fdc6e62e01a8f271c2d249756762e9fd91f7754 /db/update.d/01_faq.php | |
parent | bc471460fc8cce0bb9d8b5631e8d57fdec6a3b39 (diff) |
database update script
Diffstat (limited to 'db/update.d/01_faq.php')
-rw-r--r-- | db/update.d/01_faq.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/db/update.d/01_faq.php b/db/update.d/01_faq.php new file mode 100644 index 00000000..92a7376d --- /dev/null +++ b/db/update.d/01_faq.php @@ -0,0 +1,16 @@ +<?php +if(sql_num_query("DESCRIBE `FAQ` `Sprache`") === 0) { + sql_query("ALTER TABLE `FAQ` + ADD `Sprache` SET('de', 'en') NOT NULL, + ADD INDEX(`Sprache`)"); + $res = sql_query("SELECT * FROM `FAQ` WHERE `Sprache` = ''"); + while($row = mysql_fetch_assoc($res)) { + $question = explode('<br>', $row['Frage'], 2); + $answer = explode('<br>', $row['Antwort'], 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']); + } + + $applied = true; +} +?> |