protected static function init()
 {
     $countries = array();
     array_push($countries, new Country('Austria', 'at', array(new State('Styria'), new State('Tyrol'))));
     array_push($countries, new Country('Canada', 'ca', array(new State('Ontario'), new State('Quebec'))));
     array_push($countries, new Country('Luxembourg', 'lu'));
     self::$countries = $countries;
 }
 public static function init()
 {
     $countries = array();
     array_push($countries, new Country('Germany', 'ger', array(new State('Styria'), new State('Viena'))));
     array_push($countries, new Country('United States', 'usa', array(new State('Montreal'), new State('Quebek'))));
     array_push($countries, new Country('Luxenburgo', 'lux'));
     self::$countries = $countries;
 }
예제 #3
0
 protected static function init()
 {
     $countries = array();
     array_push($countries, new Country('India', 'at', array(new State('Styria'), new State('Vienna'))));
     array_push($countries, new Country('Canada', 'ca', array(new State('Ontario'), new State('bigtities'))));
     array_push($countries, new Country('USA', 'us', array(new State('Texas'), new State('Los Angeles'))));
     self::$countries = $countries;
 }
예제 #4
0
<?php

include "../models/CountryRepository.php";
$config = (include "../db/config.php");
$db = new PDO($config["db"], $config["username"], $config["password"]);
$countries = new CountryRepository($db);
switch ($_SERVER["REQUEST_METHOD"]) {
    case "GET":
        $result = $countries->getAll();
        break;
}
header("Content-Type: application/json");
echo json_encode($result);
<?php

require '../classes/CountryRepository.php';
header('Content-type: application/json');
echo ")]}'\n";
//this is a feature of angularjs that prevents
//users from trying to parse json info
$countries = CountryRepository::getCountries();
echo json_encode($countries);
<?php

require '../classes/CountryRepository.php';
header('Content-type: application/json');
echo ")]}'\n";
if (isset($_GET['countryCode']) && is_string($_GET['countryCode'])) {
    $states = CountryRepository::getStates($_GET['countryCode']);
    echo json_encode($states);
}