view 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
line wrap: on
line source

<?php

class HomeModel {
	public function Index() {
		return array("Index Value 1", "Value 2", "Value 3");
	}
    
    public function Test() {

    	/* uncomment to do the merge
    	// merge books table with books_info table
    	$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";
    	
    	$result = mysql_query($query);
        if (!$result) {
            return json_encode("Failed during selecting books, books_info table.");
        }
        $query = "ALTER TABLE books_v1 ADD Column volume VARCHAR(50), ADD Column author VARCHAR(100), ADD Column edition VARCHAR(100);"
        $result_alter = mysql_query($query);

        while ($row = mysql_fetch_assoc($result)) {
        	// insert row into books_v1 table
        	echo $row['volume'].$row['author'].$row['edition'].$row['books_id'];
            
            $query_update = "UPDATE books_v1 SET `volume`='".$row['volume']."', `author`='".$row['author']."',`edition`='".$row['edition']."' WHERE `id`='".$row['books_id']."'";
				      
            $result_update= mysql_query($query_update);
            if (!$result_update) {
                echo json_encode("error");

            }
        }
		*/
        return;
    }
    
}



?>