示例#1
0
<?php

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    require_once '../../models/record.php';
    require_once '../../models/book.php';
    require_once '../../models/person.php';
    require_once '../../models/tool.php';
    $action = $_GET['action'];
    $query = $_GET['query'];
    $type = $_GET['type'];
    switch ($action) {
        case 'getbooks':
            if ($type == 0) {
                $books = BookManager::searchBooks($query, 1, -1);
            } else {
                $books = BookManager::searchBooksBySunccoNo($query, 1, -1);
            }
            if ($books === false) {
                return;
            }
            $bookNames = array();
            $bookCount = count($books['books']);
            for ($i = 0; $i < $bookCount; $i++) {
                $book = $books['books'][$i];
                $bookNames[$i] = $book->name . "_" . $book->bookId . "_" . $book->sunccoNo;
            }
            echo JSON($bookNames);
            return;
            break;
        case 'getpersons':
            if ($type == 0) {