示例#1
0
文件: select.php 项目: Andrecg/SISTEX
<?php

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
//Get table to be accessed in DB and possible parent related
@($option = $request->option);
@($parentId = $request->parentId);
switch ($option) {
    //Country case
    case "Country":
        //Load Country VO and DAO files
        include '/VO/CountryVO.php';
        include '/DAO/CountryDAO.php';
        $countryDAO = new CountryDAO();
        //Get all countries
        $optionVO = $countryDAO->getCountries();
        //getData
        break;
        //State case
    //State case
    case "State":
        //Load State VO and DAO files
        include '/VO/StateVO.php';
        include '/DAO/StateDAO.php';
        $stateDAO = new stateDAO();
        //Get all states of a country
        $optionVO = $stateDAO->getAllByCountry($parentId);
        //getData
        break;
        //City case
    //City case
示例#2
0
include '/VO/CountryVO.php';
include '/DAO/CountryDAO.php';
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
@($tag = $request->tag);
$countryDAO = new CountryDAO();
switch ($tag) {
    case "insert":
        //Create a country with all info from http
        @($name = $request->name);
        $countryVO = new CountryVO('', $name);
        return $countryDAO->save($countryVO);
        break;
    case "select":
        //Get all countries
        $countryVO = $countryDAO->getCountries();
        break;
    case "update":
        //Delete a country
        @($id = $request->id);
        $countryVO = $countryDAO->getById_country($id_country);
        return $countryDAO->delete($countryVO);
        break;
}
$country = "";
//Send all countries separated by ';'
for ($i = 0; $i < count($countryVO); $i++) {
    $country = $country . $countryVO[$i]->toString() . ';';
}
echo $country;
?>