view models/home.php @ 81:f1f849d31272 extractapp

book_id as string
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 23 Apr 2015 14:58:27 +0200
parents 97c1e5102a22
children
line wrap: on
line source

<?php
/*
 * home.php
 * This file is part of Extraction-interface.
 *
 * Extraction-interface is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Extraction-interface is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Extraction-interface.  If not, see <http://www.gnu.org/licenses/>.
*/
class HomeModel {
    
    public function MergeBooksInfoToBooks() {
        /** 
        * This function is used to update book table in database. 
        * It merged some fields in books_info table into books table, but it has not been used now.
        */
        
        /* 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;

    }
    
}



?>