comparison models/home.php @ 51:840cdb52f476 extractapp

add book_meta into file
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 26 Mar 2015 15:42:50 +0100
parents 886f43b26ee2
children 97c1e5102a22
comparison
equal deleted inserted replaced
50:3e42a63de0ea 51:840cdb52f476
5 return array("Index Value 1", "Value 2", "Value 3"); 5 return array("Index Value 1", "Value 2", "Value 3");
6 } 6 }
7 7
8 public function Test() { 8 public function Test() {
9 9
10 /* uncomment to do the merge
11 // merge books table with books_info table
12 $query = "SELECT books_info.volume, books_info.author, books_info.edition, books_info.books_id FROM books INNER JOIN books_info ON books.id=books_info.books_id";
13 10
14 $result = mysql_query($query); 11 return;
12 }
13 public function MergeBooksInfoToBooks() {
14 /* uncomment to do the merge
15 // merge books table with books_info table
16 $query = "SELECT books_info.volume, books_info.author, books_info.edition, books_info.books_id FROM books INNER JOIN books_info ON books.id=books_info.books_id";
17
18 $result = mysql_query($query);
15 if (!$result) { 19 if (!$result) {
16 return json_encode("Failed during selecting books, books_info table."); 20 return json_encode("Failed during selecting books, books_info table.");
17 } 21 }
18 $query = "ALTER TABLE books_v1 ADD Column volume VARCHAR(50), ADD Column author VARCHAR(100), ADD Column edition VARCHAR(100);" 22 $query = "ALTER TABLE books_v1 ADD Column volume VARCHAR(50), ADD Column author VARCHAR(100), ADD Column edition VARCHAR(100);"
19 $result_alter = mysql_query($query); 23 $result_alter = mysql_query($query);
20 24
21 while ($row = mysql_fetch_assoc($result)) { 25 while ($row = mysql_fetch_assoc($result)) {
22 // insert row into books_v1 table 26 // insert row into books_v1 table
23 echo $row['volume'].$row['author'].$row['edition'].$row['books_id']; 27 echo $row['volume'].$row['author'].$row['edition'].$row['books_id'];
24 28
25 $query_update = "UPDATE books_v1 SET `volume`='".$row['volume']."', `author`='".$row['author']."',`edition`='".$row['edition']."' WHERE `id`='".$row['books_id']."'"; 29 $query_update = "UPDATE books_v1 SET `volume`='".$row['volume']."', `author`='".$row['author']."',`edition`='".$row['edition']."' WHERE `id`='".$row['books_id']."'";
26 30
27 $result_update= mysql_query($query_update); 31 $result_update= mysql_query($query_update);
28 if (!$result_update) { 32 if (!$result_update) {
29 echo json_encode("error"); 33 echo json_encode("error");
30 34
31 } 35 }
32 } 36 }
33 */ 37 */
34 return; 38 return;
39
35 } 40 }
36 41
37 } 42 }
38 43
39 44