<?php
	require_once '../../autoload.php';

	$result = array (
			"status"	=> 'KO',
			"results"	=> array ()
	);
	
	$pdo = getPDO ();
		
	if ( $pdo )
	{
		$sql = "select id,name from civilitylist order by id";

		$s0 = $pdo->prepare ( $sql );
		
		if ( $s0->execute () )
		{
			$result['status'] ='OK';

			$d0 = $s0->fetchAll ();

			for ( $i=0; $i<count($d0); $i++ )
			{
				$res = array (	"id" 	=> $d0[$i]['id'],
								"name"	=> $d0[$i]['name'] );

				array_push ( $result['results'], $res );
			}
		}
	}
	
	header('Content-type: application/json');
	
	echo json_encode ( $result );
?>