comparison develop/models/home.php @ 26:579f03f8bee5

merge table books_info into table books (execute Home/Test)
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 03 Mar 2015 10:33:42 +0100
parents 63e08b98032f
children
comparison
equal deleted inserted replaced
25:4b6d2d7e706e 26:579f03f8bee5
4 public function Index() { 4 public function Index() {
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 return array("Test Value 1", "Value 2", "Value 3"); 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
14 $result = mysql_query($query);
15 if (!$result) {
16 return json_encode("Failed during selecting books, books_info table.");
17 }
18 $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);
20
21 while ($row = mysql_fetch_assoc($result)) {
22 // insert row into books_v1 table
23 echo $row['volume'].$row['author'].$row['edition'].$row['books_id'];
24
25 $query_update = "UPDATE books_v1 SET `volume`='".$row['volume']."', `author`='".$row['author']."',`edition`='".$row['edition']."' WHERE `id`='".$row['books_id']."'";
26
27 $result_update= mysql_query($query_update);
28 if (!$result_update) {
29 echo json_encode("error");
30
31 }
32 }
33 */
34 return;
10 } 35 }
11 36
12 } 37 }
13 38
14 39