-
Notifications
You must be signed in to change notification settings - Fork 0
/
tempRefresh.php
35 lines (31 loc) · 1.54 KB
/
tempRefresh.php
1
<?php $db = new SQLite3('DatabaseVocabulary.db'); $db->exec('DROP TABLE IF EXISTS temp_word'); $db->exec('DROP TABLE IF EXISTS temp_video'); $db->exec('CREATE TABLE IF NOT EXISTS temp_word (word_id INT NOT NULL, word TEXT NOT NULL, wordlist_id INT NOT NULL)'); $db->exec('CREATE TABLE IF NOT EXISTS temp_video (movie_name TEXT NOT NULL, file_name TEXT NOT NULL, youkuId TEXT NOT NULL)'); $selected = ""; $youkuIds = array(); $word_id = htmlspecialchars($_GET["wordId"]); if ($word_id == 0) { $db->exec('INSERT INTO temp_word (word_id, word, wordlist_id) VALUES (0, "", 0);'); } else { $results = $db->query('SELECT * FROM word where id=' . $word_id); while ($row = $results->fetchArray()) { $db->exec('INSERT INTO temp_word (word_id, word, wordlist_id) VALUES (' . $word_id . ', "' . $row['word'] . '", ' . $row['wordlist_id'] . ');'); } $results = $db->query('SELECT * FROM word_video INNER JOIN video ON word_video.video_id = video.video_id INNER JOIN word ON word_video.word_id = word.id where word.id='. $word_id); while ($row = $results->fetchArray()) { $db->exec('INSERT INTO temp_video (movie_name, file_name, youkuId) VALUES ("' . $row['movie_name'] . '", "' . $row['file_name'] . '", "' . $row['youku_id'] . '");'); $selected = "?selected=0"; array_push($youkuIds, $row['youku_id']); } } $db->close(); $returnObj = new stdClass(); $returnObj->wordId = $word_id; $returnObj->location = "addWord.php" . $selected; $returnObj->youkuIds = $youkuIds; $returnJSON = json_encode($returnObj); echo $returnJSON;?>