<?php
require_once '_db.php';



$json = file_get_contents('php://input');
$params = json_decode($json);

$capacity = isset($params->Designation) ? $params->Designation : '0';

$stmt = $db->prepare("SELECT * FROM person WHERE Designation = :Designation OR :Designation = '0' ORDER BY last,first");
$stmt->bindParam(':Designation', $Designation); 
$stmt->execute();
$list= $stmt->fetchAll();


/*
$stmt = $db->prepare("SELECT * FROM person ORDER BY last, first");
$stmt->execute();
$list = $stmt->fetchAll();
*/

class Employee {}

$result = array();

foreach($list as $employee) {
  $r = new Employee();
  $r->id = $employee['id'];
  $r->name = $employee['last'].', '.$employee['first'];
  $r->Designation = intval($room['Designation']);
  $result[] = $r;
  
}

header('Content-Type: application/json');
echo json_encode($result);

?>




